fix(cli): remove AGP 9 property shims and jcenter() in cap migrate - #8584
Draft
andredestro wants to merge 1 commit into
Draft
fix(cli): remove AGP 9 property shims and jcenter() in cap migrate#8584andredestro wants to merge 1 commit into
andredestro wants to merge 1 commit into
Conversation
Android Studio's AGP Upgrade Assistant writes a set of compatibility flags into gradle.properties to keep the AGP 8 defaults. A Capacitor app needs none of them: most are deprecated and will be removed in AGP 10, and a couple break a Capacitor 9 build (android.builtInKotlin=false disables the Kotlin support AGP 9 bundles). Strip them during migration. Gradle 9 also removed jcenter(), which fails at the configuration phase, so drop it from the root and app build.gradle and make sure the block it lived in declares mavenCentral(). Both steps run before the gradle wrapper upgrade: the wrapper task runs on Gradle 9.5.1 the second time around, so a leftover jcenter() would fail it.
andredestro
requested review from
ItsChaceD,
OS-pedrogustavobilro,
OS-ruimoreiramendes,
alexgerardojacinto,
jcesarmobile,
markemer and
theproducer
August 28, 2026 11:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends
cap migratewith two Android cleanup steps that Gradle 9 / AGP 9 make necessary:gradle.properties: removes the 10 compatibility flags that Android Studio's AGP Upgrade Assistant writes to preserve the AGP 8 defaults.android.useAndroidX=trueis kept.jcenter(): removes it fromandroid/build.gradleandandroid/app/build.gradle, and makes sure therepositoriesblock it lived in declaresmavenCentral().Both steps run before the gradle wrapper upgrade. The wrapper task runs on Gradle 9.5.1 the second time around, so a leftover
jcenter()would fail it at the configuration phase and the wrapper upgrade would be lost.Unlike the Capacitor 3 -> 4 migrator, the
jcenter()removal is no longer opt-in, and it only touchesrepositoriesblocks that actually containjcenter(), so the nestedflatDirblock in a Capacitor 8app/build.gradleis left alone.Adds
cli/test/migrate-android-gradle.spec.ts: 19 tests covering the transformations and a block that runs them against a project on disk.Change Type
Rationale / Problems Fixed
Users have been running the AGP 9 migration in Android Studio while still on Capacitor 8. The Assistant injects flags that a Capacitor app does not need: most are deprecated and will be removed in AGP 10, and a couple break a Capacitor 9 build (
android.builtInKotlin=falsedisables the Kotlin support AGP 9 now bundles,android.sdk.defaultTargetSdkToCompileSdkIfUnset=falsestops AGP from inferringtargetSdkVersion).RepositoryHandler.jcenter()was removed in Gradle 9.0. Anybuild.gradlethat still calls it fails immediately at the configuration phase withCould not find method jcenter().Platforms Affected