fix(android): drop the unused kotlin-android plugin - #644
gabrieldonadel wants to merge 2 commits into
Conversation
…in extension AGP 9 ships built-in Kotlin support and registers the kotlin extension itself. Applying the Kotlin plugin again fails configuration with "Cannot add extension with name 'kotlin'". Check for the extension directly, which needs no AGP version table and covers AGP 10, where the android.builtInKotlin opt-out is removed.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@googlebot I signed it! |
jokerttu
left a comment
There was a problem hiding this comment.
Thanks for the report; the collision is real.
I'd rather fix it at the root than guard it, though.
See the suggestion.
Per maintainer review: this module has no Kotlin sources, so the guard is unnecessary and the apply can simply be removed. The library module holds 33 .java files and no .kt files; the only Kotlin in the repo lives in example/android/app, which is a separate Gradle project with its own build file. Android codegen emits Java here, per the javaPackageName in codegenConfig. Nothing else in this build file depends on the Kotlin plugin -- there is no kotlinOptions block and no Kotlin stdlib dependency. Co-authored-by: gabrieldonadel <11707729+gabrieldonadel@users.noreply.github.com>
|
Agreed — you're right, and removing it is the better fix here. Applied in I checked the module before taking it, since the guard is the right answer in most of the
So the plugin was a no-op on AGP 8 too, not just redundant on AGP 9. Title and description Worth flagging one thing for whenever you do move this module to Kotlin: under AGP 9, |
Problem
Android Gradle Plugin 9 ships built-in Kotlin support and enables it by default, so
AGP registers the
kotlinextension itself. When a library also applieskotlin-androidexplicitly, the two collide and configuration fails before anything compiles:
The apply is unconditional in this file, so on an AGP 9 project this module cannot be
built at all.
Change
Remove the
kotlin-androidapply.apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' apply plugin: 'com.facebook.react'Files changed:
android/build.gradleThis PR originally guarded the apply behind a check for the
kotlinextension. At@jokerttu's suggestion it now removes the line instead, which is the better fix here:
the module has no Kotlin to compile, so the plugin was doing nothing on any AGP version.
Why removal is safe in this module
android/srcholds 33.javafiles and no.ktfiles. The only Kotlin in therepository is under
example/android/app, which is a separate Gradle project with itsown build file and is unaffected.
codegenConfigsetsandroid.javaPackageName— sothe
generated/javaandgenerated/jnidirectories added tosourceSets.main.java.srcDirscontain no Kotlin either.
android/build.gradledepends on the Kotlin plugin: nokotlinOptionsblock, no Kotlin stdlib dependency, no
kotlin.srcDirs.Because there are no Kotlin sources, this is a no-op on AGP 8 as well as a fix on AGP 9 —
compileDebugKotlinhad nothing to do before and does not exist now.What I verified, and what I did not
above.
Phases.CONVERSIONsyntax check.and I could not do that from outside.
Found while sweeping popular React Native libraries for AGP 9 new-DSL compatibility,
where this collision was by far the most common blocker. Most libraries do have Kotlin
sources and need the guard; this one does not, and is better off without the plugin.