AGP 9: Final phase - Gradle/AGP upgrade#22727
AGP 9: Final phase - Gradle/AGP upgrade#22727nbradbury merged 15 commits intofeature/agp9-feature-branchfrom
Conversation
Simultaneously upgrade Gradle (8.12.1 → 9.1.0) and AGP (8.10.1 → 9.0.1)
since AGP 8.x does not support Gradle 9.x.
Uses opt-out flags (android.newDsl=false, android.builtInKotlin=false) to
preserve existing kotlin-android/kapt plugins while on AGP 9.
Version bumps:
- Gradle 8.12.1 → 9.1.0
- AGP 8.10.1 → 9.0.1
- Dagger/Hilt 2.58 → 2.59.2
- Fladle 0.19.0 → 0.21.0
AGP 9 migration fixes:
- Remove archivesBaseName from defaultConfig (use base.archivesName)
- Move compileSdk from defaultConfig to android block
- Replace proguard-android.txt with proguard-android-optimize.txt
- Rename lintOptions → lint in root build.gradle
- Replace deprecated buildDir with layout.buildDirectory
- Remove obsolete android.useAndroidX and android.enableJetifier properties
- Fix kotlin {} → java {} for sourceCompatibility in JVM-only modules
- Remove allowBackup from posttypes library manifest (app-level concern)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove android.newDsl=false and android.builtInKotlin=false to fully adopt AGP 9's new DSL and built-in Kotlin compilation support. - Remove kotlin-android plugin from all modules (AGP 9 built-in) - Migrate kapt → legacy-kapt in fluxc (AGP 9 requirement) - Migrate applicationVariants API → androidComponents.onVariants - Remove kotlin-android and kapt entries from version catalog - Keep kotlin-compose plugin (still required for Compose compiler) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove android.nonTransitiveRClass and android.nonFinalResIds (now always enabled in AGP 9) and android.enableR8.fullMode=false to adopt the new default of full R8 mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Re-add android.enableR8.fullMode=false to preserve the previous R8 behavior. Enabling full mode can be done as a separate follow-up after verifying keep rules with a release build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sistency Migrate packagingOptions to packaging with resources block in WordPress and editor modules, and align analytics module compileOptions to use JvmTarget.fromTarget() matching all other modules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
|
|
…oncat Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/jetpackRelease/base_manifest.txt 2026-03-24 10:54:30.520755489 +0000
+++ ./build/reports/diff_manifest/WordPress/jetpackRelease/head_manifest.txt 2026-03-24 10:54:41.690803726 +0000
@@ -180,11 +180,9 @@
</activity> <!-- Web Links Deep Linking Activity Alias -->
<activity-alias
android:name="org.wordpress.android.WebLinksDeepLinkingIntentReceiverActivity"
- android:excludeFromRecents="true"
android:exported="true"
android:label="@string/deep_linking_weblinks_alias_label"
- android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity"
- android:theme="@style/WordPress.NoActionBar" >
+ android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity" >
<intent-filter android:autoVerify="true" >
<action android:name="android.intent.action.VIEW" />
@@ -303,11 +301,9 @@
</activity-alias> <!-- Custom Wordpress URI Scheme Deep Linking Activity Alias -->
<activity-alias
android:name="org.wordpress.android.URISchemeDeepLinkingIntentReceiverActivity"
- android:excludeFromRecents="true"
android:exported="true"
android:label="@string/deep_linking_urilinks_alias_label"
- android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity"
- android:theme="@style/WordPress.NoActionBar" >
+ android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Go to https://buildkite.com/automattic/wordpress-android/builds/25662/canvas?sid=019d1f73-8371-4d82-9e12-295b0502575c, click on the |
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/wordpressRelease/base_manifest.txt 2026-03-24 10:54:52.398733600 +0000
+++ ./build/reports/diff_manifest/WordPress/wordpressRelease/head_manifest.txt 2026-03-24 10:55:08.568769840 +0000
@@ -573,11 +573,9 @@
</activity> <!-- Web Links Deep Linking Activity Alias -->
<activity-alias
android:name="org.wordpress.android.WebLinksDeepLinkingIntentReceiverActivity"
- android:excludeFromRecents="true"
android:exported="true"
android:label="@string/deep_linking_weblinks_alias_label"
- android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity"
- android:theme="@style/WordPress.NoActionBar" >
+ android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity" >
<intent-filter android:autoVerify="true" >
<action android:name="android.intent.action.VIEW" />
@@ -696,11 +694,9 @@
</activity-alias> <!-- Custom Wordpress URI Scheme Deep Linking Activity Alias -->
<activity-alias
android:name="org.wordpress.android.URISchemeDeepLinkingIntentReceiverActivity"
- android:excludeFromRecents="true"
android:exported="true"
android:label="@string/deep_linking_urilinks_alias_label"
- android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity"
- android:theme="@style/WordPress.NoActionBar" >
+ android:targetActivity="org.wordpress.android.ui.deeplinks.DeepLinkingIntentReceiverActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Go to https://buildkite.com/automattic/wordpress-android/builds/25662/canvas?sid=019d1f73-8370-4104-843d-b292ffdc60db, click on the |
Replace deprecated onBackPressed() in JetpackFullPluginInstallActivity with OnBackPressedCallback for Android 16+ predictive back gesture support. Fix missing spaces in string concatenations across 4 files (ApplicationPasswordsConfiguration, MediaUploadHandler, ReaderTagsFeedPostListItem, GutenbergContainerFragment). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/agp9-feature-branch #22727 +/- ##
============================================================
Coverage 37.34% 37.34%
============================================================
Files 2316 2316
Lines 123272 123272
Branches 16712 16712
============================================================
Hits 46042 46042
Misses 73531 73531
Partials 3699 3699 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
AGP 9 requires proguard-android-optimize.txt, which enables aggressive R8 optimizations that can strip code accessed via reflection (Gson, FluxC, React Native). Adding -dontoptimize to proguard.cfg preserves the safe behavior of the old proguard-android.txt default. Optimization can be enabled in a separate, well-tested PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
General checks look good. You might want to double check this one:
|
adalpari
left a comment
There was a problem hiding this comment.
Great progress with the migration!!
LGTM!
This is a good catch, and I'm surprised my review didn't spot it. I pointed Claude at your comment and it had this to say:
I'll look into this further then update this PR once I'm confident of the changes. |
…rget JvmTarget.fromTarget().target returns a String, but compileOptions expects JavaVersion. Revert all modules to use JavaVersion.toVersion() which is the correct API for sourceCompatibility/targetCompatibility. Remove unused JvmTarget imports from modules that no longer need them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Migrate kotlinOptions to compilerOptions in root build.gradle - Use .configureEach instead of eager .all for KotlinCompile tasks - Remove deprecated org.gradle.configureondemand (incompatible with configuration cache) - Remove android.enableR8.fullMode=false (removed in AGP 9; -dontoptimize in proguard.cfg provides equivalent protection) - Add explicit compileOptions to networking and mocks modules for consistency with all other modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The dependency path is intentionally dynamic for local/remote substitution and cannot be moved to the version catalog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
@adalpari I resolved that issue then asked Claude for a thorough review:
I'll merge this into the feature branch, then prepare that for review. |
* Upgrade Gradle 9.1.0 + AGP 9.0.1
Simultaneously upgrade Gradle (8.12.1 → 9.1.0) and AGP (8.10.1 → 9.0.1)
since AGP 8.x does not support Gradle 9.x.
Uses opt-out flags (android.newDsl=false, android.builtInKotlin=false) to
preserve existing kotlin-android/kapt plugins while on AGP 9.
Version bumps:
- Gradle 8.12.1 → 9.1.0
- AGP 8.10.1 → 9.0.1
- Dagger/Hilt 2.58 → 2.59.2
- Fladle 0.19.0 → 0.21.0
AGP 9 migration fixes:
- Remove archivesBaseName from defaultConfig (use base.archivesName)
- Move compileSdk from defaultConfig to android block
- Replace proguard-android.txt with proguard-android-optimize.txt
- Rename lintOptions → lint in root build.gradle
- Replace deprecated buildDir with layout.buildDirectory
- Remove obsolete android.useAndroidX and android.enableJetifier properties
- Fix kotlin {} → java {} for sourceCompatibility in JVM-only modules
- Remove allowBackup from posttypes library manifest (app-level concern)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove AGP 9 opt-out flags and adopt built-in Kotlin
Remove android.newDsl=false and android.builtInKotlin=false to fully
adopt AGP 9's new DSL and built-in Kotlin compilation support.
- Remove kotlin-android plugin from all modules (AGP 9 built-in)
- Migrate kapt → legacy-kapt in fluxc (AGP 9 requirement)
- Migrate applicationVariants API → androidComponents.onVariants
- Remove kotlin-android and kapt entries from version catalog
- Keep kotlin-compose plugin (still required for Compose compiler)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove obsolete AGP 9 gradle.properties flags
Remove android.nonTransitiveRClass and android.nonFinalResIds (now
always enabled in AGP 9) and android.enableR8.fullMode=false to adopt
the new default of full R8 mode.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Keep R8 full mode disabled to reduce migration risk
Re-add android.enableR8.fullMode=false to preserve the previous R8
behavior. Enabling full mode can be done as a separate follow-up
after verifying keep rules with a release build.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* AGP 9: Replace deprecated packagingOptions and fix compileOptions consistency
Migrate packagingOptions to packaging with resources block in WordPress
and editor modules, and align analytics module compileOptions to use
JvmTarget.fromTarget() matching all other modules.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix lint errors: remove invalid activity-alias attrs and fix string concat
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix lint errors: migrate onBackPressed and fix TextConcatSpace warnings
Replace deprecated onBackPressed() in JetpackFullPluginInstallActivity
with OnBackPressedCallback for Android 16+ predictive back gesture
support. Fix missing spaces in string concatenations across 4 files
(ApplicationPasswordsConfiguration, MediaUploadHandler,
ReaderTagsFeedPostListItem, GutenbergContainerFragment).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add -dontoptimize to ProGuard rules for release safety
AGP 9 requires proguard-android-optimize.txt, which enables aggressive
R8 optimizations that can strip code accessed via reflection (Gson,
FluxC, React Native). Adding -dontoptimize to proguard.cfg preserves
the safe behavior of the old proguard-android.txt default. Optimization
can be enabled in a separate, well-tested PR.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add comment explaining -dontoptimize in ProGuard rules
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert compileOptions to use JavaVersion.toVersion() instead of JvmTarget
JvmTarget.fromTarget().target returns a String, but compileOptions
expects JavaVersion. Revert all modules to use JavaVersion.toVersion()
which is the correct API for sourceCompatibility/targetCompatibility.
Remove unused JvmTarget imports from modules that no longer need them.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix stale comment referencing Java 1.8 instead of version catalog
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix deprecated Gradle/AGP 9 config and add missing compileOptions
- Migrate kotlinOptions to compilerOptions in root build.gradle
- Use .configureEach instead of eager .all for KotlinCompile tasks
- Remove deprecated org.gradle.configureondemand (incompatible with
configuration cache)
- Remove android.enableR8.fullMode=false (removed in AGP 9;
-dontoptimize in proguard.cfg provides equivalent protection)
- Add explicit compileOptions to networking and mocks modules for
consistency with all other modules
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Suppress UseTomlInstead lint error for dynamic GutenbergKit dependency
The dependency path is intentionally dynamic for local/remote
substitution and cannot be moved to the version catalog.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>





This is the final PR - other than the feature branch - for the AGP 9 upgrade project. Unlike previous PRs in this project, lint and unit tests should not be failing on this one.
Summary
packagingOptionswith AGP 9packaging { resources { ... } }DSL inWordPress/build.gradleandlibs/editor/build.gradlecompileOptionsin all modules to useJavaVersion.toVersion()instead ofJvmTarget.fromTarget().target, which returned a String instead of the expectedJavaVersiontypekotlinOptionstocompilerOptionsin rootbuild.gradle, and uses lazy.configureEachinstead of eager.allforKotlinCompiletasksorg.gradle.configureondemand=truefromgradle.properties(incompatible with configuration cache)android.enableR8.fullMode=falsefromgradle.properties(property removed in AGP 9;-dontoptimizeinproguard.cfgprovides equivalent protection)-dontoptimizetoproguard.cfgfor release safety — AGP 9 requiresproguard-android-optimize.txtwhich enables aggressive R8 optimizations that can strip reflection-accessed code (Gson, FluxC, React Native). This preserves the safe behavior of the oldproguard-android.txtdefault.compileOptionstolibs/networkingandlibs/mocksmodules for consistency with all other modulesUseTomlInsteadlint error on dynamic GutenbergKit dependency inlibs/editor/build.gradle(path is intentionally dynamic for local/remote substitution)activity-aliasattributes and fixes string concatenation lint erroronBackPressed()inJetpackFullPluginInstallActivitytoOnBackPressedCallbackfor Android 16+ predictive back gesture support (GestureBackNavigation lint error)ApplicationPasswordsConfiguration,MediaUploadHandler,ReaderTagsFeedPostListItem, andGutenbergContainerFragmentTest plan
assembleWordPressDebugandassembleJetpackDebugbuild successfullylintWordPressReleaseandlintJetpackReleasepass with no new errors