From 69df5887e0365bcae520bf075213de3c5cad21d8 Mon Sep 17 00:00:00 2001 From: FlintWave Date: Thu, 11 Jun 2026 02:11:42 -0700 Subject: [PATCH] chore(build): migrate to AGP 9 + Gradle 9 + compileSdk 37 (unblocks core-ktx 1.19) androidx core-ktx 1.19.0 requires compileSdk 37 (Android 16) and AGP >= 9.1.0, so this moves the whole build toolchain forward: - AGP 8.13.2 -> 9.2.1 and the Gradle wrapper 8.14.5 -> 9.4.1 (AGP 9.2 needs Gradle 9.4.1+), with the distribution checksum updated. - compileSdk 36 -> 37; core-ktx 1.18.0 -> 1.19.0. targetSdk stays 35 (a target bump is a behaviour change for its own pass). - AGP 9 turns on built-in Kotlin + the new DSL by default, which is incompatible with the standalone kotlin.android plugin we apply alongside the version-matched Compose and serialization compiler plugins. Opt out (android.builtInKotlin=false / android.newDsl=false) so the existing Kotlin 2.4.0 toolchain keeps driving compilation. Adopting built-in Kotlin is a follow-up that must land before AGP 10 removes the opt-out. - CI and release workflows install the android-37 platform explicitly, since it is new enough that the runner image may not bake it in. ktlint + Android Lint + unit tests + debug assembly all green locally; the assembled APK reports compileSdkVersion 37. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 10 ++++++++++ .github/workflows/release.yml | 8 ++++++++ app/build.gradle.kts | 2 +- gradle.properties | 9 +++++++++ gradle/libs.versions.toml | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93acb5a..129e071 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,16 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew + # compileSdk 37 (Android 16) is new enough that the runner image may not preinstall its + # platform. Accept licenses and install it explicitly so the build does not depend on which + # SDK packages happen to be baked into ubuntu-latest. Build-tools are left to AGP's auto- + # download (licenses are accepted above), matching what it resolves locally. + - name: Install Android SDK platform 37 + run: | + sdkmanager="${ANDROID_SDK_ROOT:-$ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" + yes | "$sdkmanager" --licenses >/dev/null 2>&1 || true + "$sdkmanager" "platforms;android-37.0" + - name: ktlint, Android Lint, unit tests, debug assembly run: ./gradlew ktlintCheck lint test assembleDebug --stacktrace # Release signing, APK/SHA256SUMS publishing, F-Droid metadata and release-please live in diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1467edb..244e179 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,6 +40,14 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew + # compileSdk 37 (Android 16) may not be preinstalled on the runner image; install it + # explicitly so the release build does not depend on the baked-in SDK packages. + - name: Install Android SDK platform 37 + run: | + sdkmanager="${ANDROID_SDK_ROOT:-$ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" + yes | "$sdkmanager" --licenses >/dev/null 2>&1 || true + "$sdkmanager" "platforms;android-37.0" + - name: Decode signing keystore env: SIGNING_KEY_BASE64: ${{ secrets.SIGNING_KEY_BASE64 }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 76a4bb8..e59023a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -61,7 +61,7 @@ val appVersionCode = android { namespace = "org.searchmob" - compileSdk = 36 + compileSdk = 37 defaultConfig { applicationId = "org.searchmob" diff --git a/gradle.properties b/gradle.properties index 82379f9..1f7435c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,12 @@ org.gradle.configuration-cache=true android.useAndroidX=true android.nonTransitiveRClass=true kotlin.code.style=official + +# AGP 9 ships built-in Kotlin support and a new DSL on by default, which is incompatible with the +# standalone `org.jetbrains.kotlin.android` plugin this project applies (alongside the matching +# Compose and serialization compiler plugins pinned to our Kotlin version). Opt out for now so the +# existing, working Kotlin toolchain keeps driving compilation on AGP 9; adopting built-in Kotlin +# (and aligning the Compose/serialization plugin versions to AGP's bundled Kotlin) is a follow-up +# that must land before AGP 10 removes this opt-out. +android.builtInKotlin=false +android.newDsl=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2e74f65..2110e34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -agp = "8.13.2" +agp = "9.2.1" kotlin = "2.4.0" -coreKtx = "1.18.0" +coreKtx = "1.19.0" activityCompose = "1.13.0" lifecycleRuntimeKtx = "2.10.0" composeBom = "2024.12.01" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4cf193..8e61ef1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +distributionSha256Sum=2ab2958f2a1e51120c326cad6f385153bb11ee93b3c216c5fccebfdfbb7ec6cb +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME