#389 tracks dropping the AGP 9 opt-outs from the test app. We can't close it ourselves: the remaining blockers are both in react-native-test-app, and nobody upstream is tracking either (searched microsoft/react-native-test-app for newDsl, builtInKotlin and AGP 9 DSL — no issues, no PRs).
So this is the decision: do we report it upstream, and in what form? Filing costs nothing and the text is written. Someone with a working Android toolchain might reasonably prefer to send a PR for the built-in Kotlin half, which is a two-line change.
What we learned by building it
An earlier revision of this issue claimed the new DSL was the only blocker and that we were already running built-in Kotlin. That was wrong, and only a real Android build showed it. Building the test app with android.builtInKotlin unset (react-native-test-app 5.4.8, React Native 0.88 nightly, AGP 9.2.1) fails in react-native-test-app's own Kotlin:
e: ComponentActivity.kt:33:9 Unresolved reference 'ComponentActivityDelegate'
e: MainActivity.kt:145:9 Unresolved reference 'testApp'
e: MainActivity.kt:225:50 Unresolved reference 'reactHost'
e: MainActivity.kt:135:17 Unresolved reference 'canUseCamera'
e: MainActivity.kt:25:45 Unresolved reference 'ComponentBottomSheetDialogFragment'
Every unresolved symbol is defined in a directory the app module adds through main.java.srcDirs +=. Files under the standard src/main/java compile; nothing from an added directory does. The Kotlin plugin adds those directories to the Kotlin source set, AGP's built-in Kotlin does not.
So there are two independent blockers, and the useBuiltInKotlin gate addresses neither — it prevents the plugin-conflict failure, but the module still needs the plugin to compile at all.
Two things that shape the ask
- react-native-test-app is mirroring React Native, not making its own call. The commit that added the opt-outs (11c4fff) says "See react-native-community/template@775d99a". Asking them to change the template default is asking them to diverge from React Native, and they'd be right to decline. The ask is only that their modules stop forcing the opt-outs on projects that are otherwise ready.
- The flags are coupled, one way.
builtInKotlin=false requires newDsl=false, so the built-in Kotlin fix is a prerequisite for the DSL one, not an alternative to it.
Paste-ready
Title:
Android: react-native-test-app forces both AGP 9 opt-outs on its consumers
Body:
The template ships `android.builtInKotlin=false` + `android.newDsl=false` as of 5.4.2 (11c4fff, mirroring react-native-community/template@775d99a). Those defaults are a sensible ecosystem-wide transition aid and this isn't a request to change them.
The narrower problem: a project that is otherwise ready for AGP 9 still cannot drop either flag, because react-native-test-app's own modules require both. Line references are against `5.4.8`.
## 1. Built-in Kotlin: sources added via `java.srcDirs` are not compiled
[`android/app/build.gradle#L188`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L188) adds the version-specific sources with `main.java.srcDirs += [...]`. The Kotlin plugin adds those directories to the Kotlin source set; AGP's built-in Kotlin only picks up the standard ones, so every Kotlin symbol defined in an added directory goes unresolved.
With `android.builtInKotlin` unset (react-native-test-app 5.4.8, React Native 0.88 nightly, AGP 9.2.1), `:app:compileReleaseKotlin` fails:
e: ComponentActivity.kt:33:9 Unresolved reference 'ComponentActivityDelegate'
e: MainActivity.kt:145:9 Unresolved reference 'testApp'
e: MainActivity.kt:225:50 Unresolved reference 'reactHost'
e: MainActivity.kt:135:17 Unresolved reference 'canUseCamera'
e: MainActivity.kt:25:45 Unresolved reference 'ComponentBottomSheetDialogFragment'
…one per symbol defined under `src/reactactivitydelegate-0.75/java`, `src/reactapplication-0.76/java`, `src/reacthost-0.76/java`, `src/camera/java` and the rest of that list.
The [`useBuiltInKotlin`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L15) gate doesn't cover this — it avoids applying the Kotlin plugin on top of built-in Kotlin, but the module still needs the plugin in order to compile.
Adding the same directories to `main.kotlin.srcDirs` alongside `main.java.srcDirs` should make the module work under both, since the Kotlin plugin honours `kotlin.srcDirs` too. Happy to send that as a PR if you'd prefer.
## 2. New DSL: old DSL in both modules
| Location | Old DSL |
| --- | --- |
| [`android/app/build.gradle#L77`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L77) | `compileSdkVersion` |
| [`android/app/build.gradle#L88`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L88) | `kotlinOptions` (already gated on `!useBuiltInKotlin`) |
| [`android/app/build.gradle#L95-L96`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L95-L96) | `minSdkVersion`, `targetSdkVersion` |
| [`android/app/build.gradle#L161`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/app/build.gradle#L161) | `lintOptions` |
| [`android/support/build.gradle#L16`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/support/build.gradle#L16) | `compileSdkVersion` |
| [`android/support/build.gradle#L19-L20`](https://github.com/microsoft/react-native-test-app/blob/4d674bcb1773a87e02aa4e3582b1b048219e56cb/android/support/build.gradle#L19-L20) | `minSdkVersion`, `targetSdkVersion` |
Since `builtInKotlin=false` requires `newDsl=false`, (1) is a prerequisite for (2) — but (1) is worth doing on its own.
**Why now:** React Native 0.87 pins AGP 9.2.1, and Android's [DSL/API migration timeline](https://developer.android.com/build/releases/gradle-plugin-roadmap) has AGP 10 (estimated late 2026) removing *both* opt-outs outright — at which point every react-native-test-app consumer needs this done, not just the ones opting in early.
Tracked on our side at callstackincubator/react-native-node-api#389.
Before filing
- Re-check that no upstream issue has appeared in the meantime.
- Re-check the line numbers against whatever the current release is — the links are permalinked to
5.4.8 (4d674bc), so they stay valid, but the ask should describe current code.
- The
main.kotlin.srcDirs suggestion is reasoned from the failure, not tested. Verifying it locally would turn this into a PR, which is the more useful contribution.
#389 tracks dropping the AGP 9 opt-outs from the test app. We can't close it ourselves: the remaining blockers are both in react-native-test-app, and nobody upstream is tracking either (searched
microsoft/react-native-test-appfornewDsl,builtInKotlinandAGP 9 DSL— no issues, no PRs).So this is the decision: do we report it upstream, and in what form? Filing costs nothing and the text is written. Someone with a working Android toolchain might reasonably prefer to send a PR for the built-in Kotlin half, which is a two-line change.
What we learned by building it
An earlier revision of this issue claimed the new DSL was the only blocker and that we were already running built-in Kotlin. That was wrong, and only a real Android build showed it. Building the test app with
android.builtInKotlinunset (react-native-test-app 5.4.8, React Native 0.88 nightly, AGP 9.2.1) fails in react-native-test-app's own Kotlin:Every unresolved symbol is defined in a directory the app module adds through
main.java.srcDirs +=. Files under the standardsrc/main/javacompile; nothing from an added directory does. The Kotlin plugin adds those directories to the Kotlin source set, AGP's built-in Kotlin does not.So there are two independent blockers, and the
useBuiltInKotlingate addresses neither — it prevents the plugin-conflict failure, but the module still needs the plugin to compile at all.Two things that shape the ask
builtInKotlin=falserequiresnewDsl=false, so the built-in Kotlin fix is a prerequisite for the DSL one, not an alternative to it.Paste-ready
Title:
Body:
Before filing
5.4.8(4d674bc), so they stay valid, but the ask should describe current code.main.kotlin.srcDirssuggestion is reasoned from the failure, not tested. Verifying it locally would turn this into a PR, which is the more useful contribution.