Repository navigation
fix(android): compile the library's Kotlin sources under AGP 9 built-in Kotlin - #1264
Merged
Merged
Conversation
…in Kotlin android/build.gradle adds src/newarch and the reactNativeVersionPatch folder to `java.srcDirs` only. Under AGP 9's built-in Kotlin, .kt files are compiled only from the `kotlin` source directories, so those folders are skipped and the library fails to compile: MenuPackage.kt:18:30 Unresolved reference 'MenuViewManager'. Collect the extra directories once, then add them to both `java.srcDirs` and `kotlin.srcDirs`. The Kotlin Gradle plugin, which is used when built-in Kotlin is off, already reads both, so this is safe there too. The React Native 0.88 template opts out with android.builtInKotlin=false, so only apps that enable built-in Kotlin hit this today. AGP 10 removes that opt-out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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/build.gradleaddssrc/newarchand thereactNativeVersionPatch/MenuViewManager/*folder tojava.srcDirsonly. Under AGP 9's built-in Kotlin,.ktfiles are compiled only from thekotlinsource directories, so those folders are skipped and the library doesn't compile:I found this while investigating the React Native 0.88 upgrade (#1249). RN 0.88 needs Gradle 9.4.1 / AGP 9.2.1. The RN 0.88 app template opts out with
android.builtInKotlin=false, so only apps that turn built-in Kotlin on hit this today. AGP 10 removes the opt-out.Change (
android/build.gradleonly)Collect the extra source directories once, then add them to both
java.srcDirsandkotlin.srcDirs. The Kotlin Gradle plugin, which is used when built-in Kotlin is off, already reads both, so listing a directory in each is safe there too. Which directories are selected doesn't change.Verification (local, example app
assembleDebug)master)compileDebugKotlinfails as abovebuiltInKotlin=false,newDsl=false)¹ The example's
:appstill fails in that setup, inside react-native-test-app's ownMainActivity.kt. rnta has the samejava.srcDirspattern, so that's outside this library.CI builds RN 0.81, so it covers only the first row.
🤖 Generated with Claude Code