fix(android): skip explicit Kotlin plugin when AGP registers the kotlin extension - #9660
fix(android): skip explicit Kotlin plugin when AGP registers the kotlin extension#9660gabrieldonadel wants to merge 1 commit 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.
|
@gabrieldonadel is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe Android build scripts for Expo Google Sign-In and Expo Passkeys now check for an existing Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The Android modules avoid duplicate Kotlin extension registration while retaining Kotlin plugin application where needed. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Warning Linked repositories: Your configuration references 7 linked repositories, but your current plan allows 5. Analyzed Comment |
|
Thanks for this! Closing in favor of #9662, which is the same change so our full CI runs on it. Added you as co-author. |
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. AGP
words it two ways, both the same problem:
The apply is unconditional in all 2 modules below, so on an AGP 9 project this cannot be built
at all. There is no consumer-side workaround short of patching the file — setting
android.builtInKotlin=falseproject-wide just to build one dependency is not areasonable ask, and that escape hatch is removed in AGP 10.
Change
Apply the plugin only when nothing has registered the
kotlinextension yet:Files changed:
packages/expo-google-signin/android/build.gradlepackages/expo-passkeys/android/build.gradleThis tests the condition that actually fails, so there is no AGP version table to
keep in sync, and it covers AGP 10 — where the
android.builtInKotlinopt-out isremoved — without a special case.
android.builtInKotlinkotlinextensionfalsetruefalseThe guard sits after
apply plugin: 'com.android.library'in every file it touches,so AGP has already registered its extensions by the time it runs. I checked that
ordering per file rather than assuming it.
What I verified, and what I did not
9.2.1 and Gradle 9.4.1:
:app:assembleDebugsucceeds both with-Pandroid.newDsl=true -Pandroid.builtInKotlin=trueand with both flags off.the flags off,
compileDebugKotlinruns from the explicitly applied plugin; withthem on the build completes without it.
Phases.CONVERSIONsyntax check.Where this came from
A sweep of 500 popular React Native libraries against the AGP 9 defaults. 152 failed
with the new DSL enabled, and 144 of those failed on exactly this collision — by
far the most common blocker. Affects
@clerk/expo-google-signin,@clerk/expo-passkeyshere.The same guard shape was accepted in
RevenueCat/react-native-purchases#1934,
at that maintainer's suggestion.