Consider filing an upstream issue with react-native-test-app to unblock the AGP 9 opt-outs
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- android, kotlin, react-native
- Lĩnh vực
- build-system, mobile
Hướng nghiên cứu
Kiểm tra lại release hiện tại của react-native-test-app và upstream issue tracker, sau đó kiểm tra android/app/build.gradle và android/support/build.gradle quanh các dòng được liên kết. Tái hiện lỗi build AGP 9 nếu có Android toolchain; được xem là hoàn tất khi gửi một upstream report hiện tại với các tham chiếu đã xác minh, hoặc xác nhận rằng một PR đã được kiểm thử là phù hợp hơn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
#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=falserequiresnewDsl=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.srcDirssuggestion is reasoned from the failure, not tested. Verifying it locally would turn this into a PR, which is the more useful contribution.
- Ngôn ngữ chính
- TypeScript
- Star
- 188
- Fork
- 10
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 3
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của callstackincubator/react-native-node-api
-
Android 🤖
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Sanity check of Hermes source directory via environment variable, when building Android projects Đang mởAndroid 🤖 good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
callstackincubator/react-native-node-api#163 · 1 bình luận ·
-
enhancement good first issue gyp-to-cmake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
callstackincubator/react-native-node-api#161 · 3 bình luận · 1 reaction ·
-
enhancement Host 🏡
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Automatable good first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 15/100
callstackincubator/react-native-node-api#424 · 1 bình luận ·
Tất cả issue của callstackincubator/react-native-node-api
Issue tương tự
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100