From ae37c1bf29bd29b54b5e195cbcc6ad15e8120082 Mon Sep 17 00:00:00 2001 From: Korcan Hussein Date: Mon, 1 Jul 2024 13:57:18 +0100 Subject: [PATCH] gradle: Upgrade gradle and packages * Upgrades the gradle version (using AGP upgrade assistant) * Upgrades android package dependencies to latest versions (using project settings upgrade tool) * Bump compile platform SDK level to 34 (required for package updates) * Bump java src compatibility version (required for api level 34) * Fix deprecated warnings * Code compile fixes to account for package changes * explicitly specify cmake version * bump NDK to latest LTS version Part-of: --- .gitlab-ci.yml | 2 +- .gitlab-ci/ci-scripts.mk | 1 + .gitlab-ci/config.yml | 10 +++--- .gitlab-ci/install-android-sdk.sh | 6 ++-- .gitlab-ci/install-ndk.sh | 16 +++++++--- .gitlab-ci/templates/install-ndk.sh.jinja | 23 ++++++++++++++ build.gradle | 31 ++++++++++--------- gradle.properties | 1 - gradle/wrapper/gradle-wrapper.properties | 2 +- src/xrt/auxiliary/android/build.gradle | 4 +-- src/xrt/ipc/android/build.gradle | 5 +-- src/xrt/targets/android_common/build.gradle | 4 +-- .../DisplayOverOtherAppsStatusFragment.kt | 2 +- src/xrt/targets/openxr_android/build.gradle | 19 +++++++----- .../AboutLibrariesNoticeFragmentProvider.kt | 1 - 15 files changed, 82 insertions(+), 45 deletions(-) create mode 100644 .gitlab-ci/templates/install-ndk.sh.jinja diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9eb2cf6f..bdde220c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -138,7 +138,7 @@ win:container_prep: .monado.variables.debian:bookworm-ndk: variables: FDO_DISTRIBUTION_VERSION: "bookworm" - FDO_DISTRIBUTION_TAG: "2024-01-16" + FDO_DISTRIBUTION_TAG: "2024-07-02" FDO_REPO_SUFFIX: ndk # Variables for build and usage of Ubuntu focal image diff --git a/.gitlab-ci/ci-scripts.mk b/.gitlab-ci/ci-scripts.mk index cb13bc378..4be4e567f 100644 --- a/.gitlab-ci/ci-scripts.mk +++ b/.gitlab-ci/ci-scripts.mk @@ -9,6 +9,7 @@ FILES_IN_SUBDIR := \ .gitlab-ci/distributions \ .gitlab-ci/reprepro.sh \ .gitlab-ci/install-android-sdk.sh \ + .gitlab-ci/install-ndk.sh \ CONFIG_FILE := .gitlab-ci/config.yml OUTPUTS := .gitlab-ci.yml \ diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml index 685d6a156..c11326bc8 100644 --- a/.gitlab-ci/config.yml +++ b/.gitlab-ci/config.yml @@ -131,13 +131,15 @@ distributions: distro_version: bookworm repo_suffix: ndk script: android_container_prep.sh - tag: "2024-01-16" + tag: "2024-07-02" # This must match ext.sharedCompileSdk in build.gradle - android_compile_sdk: 32 + android_compile_sdk: 34 # This must match buildscript.ext.buildToolsVersion in build.gradle - android_build_tools: 32.0.0 + android_build_tools: 34.0.0 + # This must match ext.ndk_version in build.gradle + android_ndk_version: r26d # look up on https://developer.android.com/studio/index.html#downloads when updating other versions - android_cli_tools: 9477386 + android_cli_tools: 11076708 packages: git: diff --git a/.gitlab-ci/install-android-sdk.sh b/.gitlab-ci/install-android-sdk.sh index c0c167b98..b7f3baf43 100755 --- a/.gitlab-ci/install-android-sdk.sh +++ b/.gitlab-ci/install-android-sdk.sh @@ -12,10 +12,10 @@ # Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ set -eo pipefail -VERSION=9477386 +VERSION=11076708 ROOT=${ROOT:-/opt/android-sdk} -ANDROID_COMPILE_SDK=${ANDROID_COMPILE_SDK:-32} -ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-32.0.0} +ANDROID_COMPILE_SDK=${ANDROID_COMPILE_SDK:-34} +ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-34.0.0} mkdir -p "$ROOT" FN=commandlinetools-linux-${VERSION}_latest.zip diff --git a/.gitlab-ci/install-ndk.sh b/.gitlab-ci/install-ndk.sh index 0baf67ac0..bd40198b5 100755 --- a/.gitlab-ci/install-ndk.sh +++ b/.gitlab-ci/install-ndk.sh @@ -1,10 +1,18 @@ #!/bin/sh -# Copyright 2018-2020, 2022, Collabora, Ltd. and the Monado contributors +# Copyright 2018-2020, 2022, 2024 Collabora, Ltd. and the Monado contributors # SPDX-License-Identifier: BSL-1.0 -# aka 21.4.7075529 -VERSION=r21e -FN=android-ndk-${VERSION}-linux-x86_64.zip +## +####################################################### +# GENERATED - DO NOT EDIT # +# see .gitlab-ci/install-ndk.sh.jinja instead # +####################################################### +## + +# Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ + +VERSION=r26d +FN=android-ndk-${VERSION}-linux.zip wget https://dl.google.com/android/repository/$FN unzip $FN -d /opt mv /opt/android-ndk-${VERSION} /opt/android-ndk diff --git a/.gitlab-ci/templates/install-ndk.sh.jinja b/.gitlab-ci/templates/install-ndk.sh.jinja new file mode 100644 index 000000000..9d86514df --- /dev/null +++ b/.gitlab-ci/templates/install-ndk.sh.jinja @@ -0,0 +1,23 @@ +#!/bin/sh +# Copyright 2018-2020, 2022, 2024 Collabora, Ltd. and the Monado contributors +# SPDX-License-Identifier: BSL-1.0 + +#{# ignore the warning, this is actually the template to edit. #}# +####################################################### +# GENERATED - DO NOT EDIT # +# see .gitlab-ci/install-ndk.sh.jinja instead # +####################################################### +#{# +Please run the following after editing: + make -f .gitlab-ci/ci-scripts.mk +#}# + +# Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ +{% for distro in distributions -%} {%- for image in distro.images if "android_ndk_version" in image %} + +VERSION={{image.android_ndk_version}} +FN=android-ndk-${VERSION}-linux.zip +wget https://dl.google.com/android/repository/$FN +unzip $FN -d /opt +mv /opt/android-ndk-${VERSION} /opt/android-ndk +{% endfor -%} {%- endfor %} diff --git a/build.gradle b/build.gradle index 428333553..02b86dfd0 100644 --- a/build.gradle +++ b/build.gradle @@ -3,27 +3,27 @@ buildscript { ext { - kotlinVersion = '1.7.10' + kotlinVersion = '2.0.0' - latestAboutLibsRelease = '8.9.4' + latestAboutLibsRelease = '11.2.2' - androidxCoreVersion = '1.8.0' - androidxAnnotationVersion = '1.3.0' - androidxAppCompatVersion = '1.5.1' - androidxLifecycleVersion = '2.5.1' - androidxConstraintLayoutVersion = '2.1.3' + androidxCoreVersion = '1.13.1' + androidxAnnotationVersion = '1.8.0' + androidxAppCompatVersion = '1.7.0' + androidxLifecycleVersion = '2.8.2' + androidxConstraintLayoutVersion = '2.1.4' androidxCardViewVersion = '1.0.0' - androidxRecyclerViewVersion = '1.2.1' + androidxRecyclerViewVersion = '1.3.2' - hiltVersion = '2.45' + hiltVersion = '2.51.1' - materialVersion = '1.8.0' + materialVersion = '1.12.0' // This is the version to download if we can't find it locally. eigenFetchVersion = '3.4.0' // If you update this, must also update .gitlab-ci/config.yml - buildToolsVersion = '32.0.0' + buildToolsVersion = '34.0.0' } repositories { google() @@ -36,8 +36,8 @@ buildscript { } plugins { // Android Gradle Plugin - id 'com.android.application' version '8.1.0' apply false - id 'com.android.library' version '8.1.0' apply false + id 'com.android.application' version '8.5.0' apply false + id 'com.android.library' version '8.5.0' apply false id 'org.jetbrains.kotlin.android' version "$kotlinVersion" apply false @@ -70,9 +70,10 @@ spotless { } ext { - ndk_version = '21.4.7075529' + cmake_version = '3.22.1' + ndk_version = '26.3.11579264' // If you update this, must also update .gitlab-ci/config.yml - sharedCompileSdk = 32 + sharedCompileSdk = 34 sharedTargetSdk = 31 sharedMinSdk = 26 diff --git a/gradle.properties b/gradle.properties index 391516dff..0c70289c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,6 @@ # Copyright 2020, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 -android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false android.nonTransitiveRClass=false android.useAndroidX = true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 284897427..bb6c19194 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/xrt/auxiliary/android/build.gradle b/src/xrt/auxiliary/android/build.gradle index 4e020dfeb..d0f9b7672 100644 --- a/src/xrt/auxiliary/android/build.gradle +++ b/src/xrt/auxiliary/android/build.gradle @@ -26,8 +26,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { resources { diff --git a/src/xrt/ipc/android/build.gradle b/src/xrt/ipc/android/build.gradle index 7b1dee2b0..a26e5de23 100644 --- a/src/xrt/ipc/android/build.gradle +++ b/src/xrt/ipc/android/build.gradle @@ -50,8 +50,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { resources { @@ -64,6 +64,7 @@ android { } buildFeatures { aidl true + buildConfig true } } diff --git a/src/xrt/targets/android_common/build.gradle b/src/xrt/targets/android_common/build.gradle index 23ac9db4f..64bff4a2a 100644 --- a/src/xrt/targets/android_common/build.gradle +++ b/src/xrt/targets/android_common/build.gradle @@ -50,8 +50,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { resources { diff --git a/src/xrt/targets/android_common/src/main/java/org/freedesktop/monado/android_common/DisplayOverOtherAppsStatusFragment.kt b/src/xrt/targets/android_common/src/main/java/org/freedesktop/monado/android_common/DisplayOverOtherAppsStatusFragment.kt index 8a7179152..348c40108 100644 --- a/src/xrt/targets/android_common/src/main/java/org/freedesktop/monado/android_common/DisplayOverOtherAppsStatusFragment.kt +++ b/src/xrt/targets/android_common/src/main/java/org/freedesktop/monado/android_common/DisplayOverOtherAppsStatusFragment.kt @@ -83,7 +83,7 @@ class DisplayOverOtherAppsStatusFragment : Fragment() { } } - @Suppress("DEPRECATION") + @Deprecated("DEPRECATION") private val isRuntimeServiceRunning: Boolean get() { var running = false diff --git a/src/xrt/targets/openxr_android/build.gradle b/src/xrt/targets/openxr_android/build.gradle index d1cd2da7d..5cedbc7c8 100644 --- a/src/xrt/targets/openxr_android/build.gradle +++ b/src/xrt/targets/openxr_android/build.gradle @@ -206,6 +206,7 @@ android { externalNativeBuild { cmake { path "${rootDir}/CMakeLists.txt" + version "${cmake_version}" } } @@ -234,8 +235,8 @@ android { enableAggregatingTask = true } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { resources { @@ -249,17 +250,19 @@ android { lint { fatal 'StopShip' } - + buildFeatures { + buildConfig true + } } aboutLibraries { // Full license text for license IDs mentioned here // will be included, even if no detected dependency uses them. - additionalLicenses { - mit - mpl_2_0 - bsl_1_0 - } + additionalLicenses = [ + "mit", + "mpl_2_0", + "bsl_1_0" + ] } dependencies { diff --git a/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/AboutLibrariesNoticeFragmentProvider.kt b/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/AboutLibrariesNoticeFragmentProvider.kt index c9e323183..5a29d6a5f 100644 --- a/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/AboutLibrariesNoticeFragmentProvider.kt +++ b/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/AboutLibrariesNoticeFragmentProvider.kt @@ -16,7 +16,6 @@ import org.freedesktop.monado.android_common.NoticeFragmentProvider class AboutLibrariesNoticeFragmentProvider @Inject constructor() : NoticeFragmentProvider { override fun makeNoticeFragment(): Fragment = LibsBuilder() - .withFields(R.string::class.java.fields) .withAboutIconShown(false) // We do this ourselves bigger .withAboutVersionShown(true) // Let the fragment show our version .withLicenseShown(true) // Not sure why you'd do this without license info