From 98ba2138c3298fed598789d972355ef4a7ac5aa0 Mon Sep 17 00:00:00 2001 From: Andre Destro Date: Fri, 28 Aug 2026 11:44:48 +0100 Subject: [PATCH 1/2] docs: cover AGP 9 gradle.properties and build.gradle version declarations The Android upgrade guide tells readers to run the AGP Upgrade Assistant but never says to clean up the compatibility flags it writes into gradle.properties, several of which break a Capacitor 9 build. Also document the explicit dependency version declarations in app/build.gradle: the implicit parent project property lookup they replace is deprecated in Gradle 9.6 and becomes an error in Gradle 10. --- docs/main/updating/9-0.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/main/updating/9-0.md b/docs/main/updating/9-0.md index 7e59a0c9..a49b3955 100644 --- a/docs/main/updating/9-0.md +++ b/docs/main/updating/9-0.md @@ -115,6 +115,27 @@ Once it's updated, Android Studio can assist with some of the updates related to ![APG Upgrade Assistant](../../../static/img/v6/docs/android/agp-upgrade-assistant.png) +### Clean up gradle.properties + +AGP 9 changed the defaults of several `gradle.properties` flags, and the AGP Upgrade Assistant writes them back explicitly so your build keeps the AGP 8 behavior. A Capacitor app needs none of them: most are deprecated and will be removed in AGP 10, and a couple actively break a Capacitor 9 build (`android.builtInKotlin=false` turns off the Kotlin support that AGP 9 now bundles, and `android.sdk.defaultTargetSdkToCompileSdkIfUnset=false` stops AGP from inferring `targetSdkVersion`). Remove them: + +```diff +# gradle.properties + +- android.defaults.buildfeatures.resvalues=true +- android.sdk.defaultTargetSdkToCompileSdkIfUnset=false +- android.enableAppCompileTimeRClass=false +- android.usesSdkInManifest.disallowed=false +- android.uniquePackageNames=false +- android.dependency.useConstraints=true +- android.r8.strictFullModeForKeepRules=false +- android.r8.optimizedResourceShrinking=false +- android.builtInKotlin=false +- android.newDsl=false +``` + +Keep `android.useAndroidX=true`. It matches the AGP 9 default and is therefore redundant, but it is harmless and the Assistant leaves it in place too. + ### Update Android Project Variables In your `variables.gradle` file, update your values to the following new minimums @@ -164,6 +185,23 @@ buildTypes { } ``` +### Declare dependency versions in your app's build.gradle + +Your `app/build.gradle` references version variables that are declared in the root project's `variables.gradle`, and relies on Gradle walking up the project hierarchy to resolve them. That implicit lookup is deprecated in Gradle 9.6 and becomes an error in Gradle 10, so declare them explicitly at the top of the file: + +```diff +apply plugin: 'com.android.application' + ++ def androidxAppCompatVersion = rootProject.ext.androidxAppCompatVersion ++ def androidxCoordinatorLayoutVersion = rootProject.ext.androidxCoordinatorLayoutVersion ++ def coreSplashScreenVersion = rootProject.ext.coreSplashScreenVersion ++ def junitVersion = rootProject.ext.junitVersion ++ def androidxJunitVersion = rootProject.ext.androidxJunitVersion ++ def androidxEspressoCoreVersion = rootProject.ext.androidxEspressoCoreVersion + +android { +``` + ### Migrate core-ktx to core `androidx.core:core` 1.19.0 merges every extension function previously shipped in `core-ktx` into `core` itself, turning `core-ktx` into an empty compatibility artifact. If your app (or an old/community plugin it depends on) still explicitly depends on `core-ktx` with a version older than `1.19.0`, you may hit a duplicate class error at build time; remove it, or depend on `core` instead: From 491cdd2827137aac0cbb9132c3e0deba2d7ac9f2 Mon Sep 17 00:00:00 2001 From: Andre Destro Date: Tue, 1 Sep 2026 16:06:20 +0100 Subject: [PATCH 2/2] docs: address review feedback on AGP 9 gradle sections --- docs/main/updating/9-0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/main/updating/9-0.md b/docs/main/updating/9-0.md index a49b3955..083e8726 100644 --- a/docs/main/updating/9-0.md +++ b/docs/main/updating/9-0.md @@ -134,8 +134,6 @@ AGP 9 changed the defaults of several `gradle.properties` flags, and the AGP Upg - android.newDsl=false ``` -Keep `android.useAndroidX=true`. It matches the AGP 9 default and is therefore redundant, but it is harmless and the Assistant leaves it in place too. - ### Update Android Project Variables In your `variables.gradle` file, update your values to the following new minimums @@ -202,6 +200,8 @@ apply plugin: 'com.android.application' android { ``` +Those are the variables the Capacitor template declares. If your app references any other variable from `variables.gradle`, for example a dependency version used by a local plugin, declare it here too. + ### Migrate core-ktx to core `androidx.core:core` 1.19.0 merges every extension function previously shipped in `core-ktx` into `core` itself, turning `core-ktx` into an empty compatibility artifact. If your app (or an old/community plugin it depends on) still explicitly depends on `core-ktx` with a version older than `1.19.0`, you may hit a duplicate class error at build time; remove it, or depend on `core` instead: