Skip to content

fix: remove AGP 9 property shims and jcenter() - #31

Merged
jcesarmobile merged 2 commits into
mainfrom
RMET-5371
Sep 3, 2026
Merged

fix: remove AGP 9 property shims and jcenter()#31
jcesarmobile merged 2 commits into
mainfrom
RMET-5371

Conversation

@jcesarmobile

Copy link
Copy Markdown
Member

the gradle.properties removal of properties is basically a copy of ionic-team/capacitor#8584 changes
for jcenter() removal I simplified it since I don't think we should be adding mavenCentral()

also removes the whole

if (project.extensions.findByName('kotlin') == null) {
    apply plugin: 'kotlin-android'
}

block instead of just apply plugin: 'kotlin-android', if present

Comment thread src/index.ts

@OS-pedrogustavobilro OS-pedrogustavobilro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Dropping some remarks of things I noticed, not related to your PR (therefore not aiming for them to be changed here)

Comment thread src/index.ts
}

function updateKotlinOptions(gradleFile: string): string {
const kotlinOptionsRegex = /kotlinOptions\s*\{\s*jvmTarget\s*=\s*['"](\d+\.?\d*)['"][\s\S]*?\}/;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to your changes, but wanted to drop a mention to some stuff I noticed when running the command against a few community capacitor plugins. Nothing to change in this PR imo, but possible future work.

1- kotlinOptions

Noticed the kotlinOptions wasn't removed for admob, which causes the build to fail (I think in AGP 8 it was only a warning?):

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method kotlinOptions() for arguments [build_1mt6yqirm3mi9g4q4hglnxi3x$_run_closure2$_closure10@51094f08] on object of type com.android.build.gradle.internal.dsl.LibraryExtensionImpl$AgpDecorated.

Per https://github.com/search?q=org%3Acapacitor-community+kotlinOptions+%7B&type=code there's stripe plugin with this configuration. Those plugins should be using a string '' to assign the jvmTarget, but are incorrectly using the enum. While it's an issue in the plugins, perhaps the plugin migrator should cover that scenario as well?

2 - JUnit

After fixing the kotlinOptions, the android build fails with another error related to JUnit (this error doesn't happen pre-migration, so might be something Gradle 9 or AGP 9 related). This isn't covered by the migrator script or any existing documentation, and I've never gotten this error before, unsure if it's because that plugin seems to be using JUnit 5 which Android seem to never have been fully on board of - but maybe it's worth looking into this more in the future.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':testDebugUnitTest' (registered by plugin 'com.android.internal.library').
> Test process encountered an unexpected problem.
   > Could not start Gradle Test Executor 2.
      > Failed to load JUnit Platform.  Please ensure that all JUnit Platform dependencies are available on the test's runtime classpath, including the JUnit Platform launcher.

Comment thread src/index.ts
filename: string,
variablesAndClasspaths: {
variables: any;
'com.android.tools.build:gradle': string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not related to any changes here, this already happens today.

I saw a community plugin https://github.com/capacitor-community/bluetooth-le/blob/main/android/build.gradle#L19 that has a different declaration for AGP, and the plugin migrator does not replace it, which causes the build to fail.

Wonder if it's worth considering these kinds of cases in the plugin migrator? (not for this PR specifically, but for future work)

@jcesarmobile

Copy link
Copy Markdown
Member Author

can you create a few JIRA tickets for those so we don't forget about them?

@jcesarmobile
jcesarmobile merged commit 67b92d2 into main Sep 3, 2026
@jcesarmobile
jcesarmobile deleted the RMET-5371 branch September 3, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants