fix(android): skip explicit Kotlin plugin when AGP provides built-in Kotlin - #1056
Closed
gabrieldonadel wants to merge 0 commit into
Closed
Conversation
gabrieldonadel
force-pushed
the
fix/agp9-built-in-kotlin
branch
from
September 2, 2026 20:34
d076dc7 to
a523007
Compare
Author
|
Sorry for the noise — I force-updated the branch to fix the indentation so it matches this file's style, which auto-closed this PR. Superseded by #1057, same change. Please review that one instead. |
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.
Problem
Android Gradle Plugin 9 ships built-in Kotlin support and enables it by default, so
AGP applies the Kotlin plugin itself. When a library also applies
kotlin-androidexplicitly, the two collide and configuration fails before anything compiles:
The apply is unconditional in this file, so on an AGP 9 project this library cannot be
built at all. There is no consumer-side workaround short of patching the file —
setting
android.builtInKotlin=falseproject-wide to build one dependency is not areasonable ask, and that escape hatch is removed in AGP 10.
Change
Keep the explicit apply, but skip it when AGP is already providing Kotlin:
Files changed:
android/build.gradleWhy the condition has this shape
Both halves are needed:
nothing else applies the Kotlin plugin, so skipping would break the build the other way.
android.builtInKotlindefaults to on in AGP 9, soonly an explicit
falsemeans "AGP is not providing Kotlin, apply it yourself". Thismirrors AGP's own default.
Behaviour matrix:
android.builtInKotlinfalsetruefalsecom.android.Version.ANDROID_GRADLE_PLUGIN_VERSIONneeds no new plugin resolution, andthe apply here already happens after
com.android.library, so AGP is on the classpath.What I verified, and what I did not
and Gradle 9.4.1:
:app:assembleDebugsucceeds both with-Pandroid.newDsl=true -Pandroid.builtInKotlin=trueand with both flags off. Sameguard, both matrices green.
Phases.CONVERSION.construction (
shouldApplyKotlinPlugin()short-circuits totrue), but a CI run isthe real confirmation and I could not do that from outside.
Found while sweeping 157 popular React Native libraries for AGP 9 new-DSL
compatibility. 34 of them failed with the new DSL enabled, and 29 of those failed on
exactly this — it is the single most common blocker by a wide margin.