diff --git a/docs/main/updating/9-0.md b/docs/main/updating/9-0.md index 7e59a0c9..083e8726 100644 --- a/docs/main/updating/9-0.md +++ b/docs/main/updating/9-0.md @@ -115,6 +115,25 @@ 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 +``` + ### Update Android Project Variables In your `variables.gradle` file, update your values to the following new minimums @@ -164,6 +183,25 @@ 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 { +``` + +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: