Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Consider filing an upstream issue with react-native-test-app to unblock the AGP 9 opt-outs

未关闭
#390 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
android, kotlin, react-native

调研方向

重新检查当前的 react-native-test-app release 和 upstream issue tracker,然后检查链接行附近的 android/app/build.gradle 和 android/support/build.gradle。如果有可用的 Android toolchain,请复现 AGP 9 构建失败;完成的标准是提交一份带有已验证引用的最新 upstream 报告,或确认经过测试的 PR 更为合适。

由索引模型根据 Issue 内容生成。

描述

Android 🤖

#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

  1. 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.
  2. 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.
主要语言
TypeScript
星标
188
派生
10
平均合并
2 天 17 小时
30 天内合并 PR
3

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/react-native-node-api 的其他 Issue

查看 callstackincubator/react-native-node-api 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。