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 摘要。