[ANDROID] NDK Version Mismatch
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
Description
Since we recently upgraded AGP to 9. The default version of ndk is now 28.2.13676358 . However RN template still ships with 27.1.12297006. I am not sure if this was intentional .
This is fine for most of the apps . But the issue comes with cpp libraries who have not defined NDK Version explicitly in their android/build.gradle. This is causing some libraries to compile with different NDK Version and crashes on startup with below error
08-18 19:38:44.358 16955 16955 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__cxa_init_primary_exception" referenced by "/data/app/~~2Cd3zF3Bjks1HLchctSxrQ==/playagerangedeclaration.example-8X6jgQwO9r3Tq7fu1l9k0Q==/base.apk!/lib/arm64-v8a/libplayagerangedeclaration.so"...
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1111)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1033)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1765)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.margelo.nitro.playagerangedeclaration.PlayAgeRangeDeclarationPackage.<clinit>(PlayAgeRangeDeclarationPackage.kt:19)
For example
Here we can notice both 27 and 28 ndk
When I specifically define NDK 27 in android/build.gradle of my library . The issue is fixed
I can see two solutions for this
- Either we can ask library to ship ndk version default. I checked in CRNL . They also dont ship currently. So maybe adding in template of CRNL and nitro
- Upgrading app template and RNGP to use 28.x.x
Steps to reproduce
- Install the Repro
- Run the example app
- It will crash
- Add
ndkVersion getExtOrDefault("ndkVersion")to the android of the library it will be fixed
React Native Version
0.87.0
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: macOS 26.6.1
CPU: (12) arm64 Apple M4 Pro
Memory: 140.44 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.16.0
path: /Users/riteshshukla/.nvm/versions/node/v24.16.0/bin/node
Yarn:
version: 3.6.1
path: /Users/riteshshukla/.nvm/versions/node/v24.16.0/bin/yarn
npm:
version: 11.13.0
path: /Users/riteshshukla/.nvm/versions/node/v24.16.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.5
- iOS 26.5
- macOS 26.5
- tvOS 26.5
- visionOS 26.5
- watchOS 26.5
Android SDK:
API Levels:
- "28"
- "31"
- "33"
- "34"
- "35"
- "36"
- "37"
Build Tools:
- 35.0.0
- 36.0.0
- 36.1.0
- 37.0.0
System Images:
- android-36 | Google APIs ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.3 AI-253.31033.145.2533.15113396
Xcode:
version: 26.6/17F113
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.16
path: /usr/bin/javac
Ruby:
version: 3.2.0
path: /Users/riteshshukla/.rvm/rubies/ruby-3.2.0/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.2.0
wanted: 20.2.0
react:
installed: 19.2.0
wanted: 19.2.0
react-native:
installed: 0.87.0
wanted: 0.87.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
8-18 19:38:43.516 15370 15485 I GED : ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 29, oppidx_max 29, oppidx_min 0
08-18 19:38:43.529 15370 15370 D BLASTBufferQueue: [VRI[GoogleDiscoverWindow]#4](f:0,a:1) destructor()
08-18 19:38:43.529 15370 15370 D BufferQueueConsumer: [VRI[GoogleDiscoverWindow]#4(BLAST Consumer)4](id:3c0a00000004,api:0,p:-1,c:15370) disconnect
08-18 19:38:44.358 16955 16955 E AndroidRuntime: FATAL EXCEPTION: main
08-18 19:38:44.358 16955 16955 E AndroidRuntime: Process: playagerangedeclaration.example, PID: 16955
08-18 19:38:44.358 16955 16955 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__cxa_init_primary_exception" referenced by "/data/app/~~2Cd3zF3Bjks1HLchctSxrQ==/playagerangedeclaration.example-8X6jgQwO9r3Tq7fu1l9k0Q==/base.apk!/lib/arm64-v8a/libplayagerangedeclaration.so"...
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1111)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1033)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1765)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.margelo.nitro.playagerangedeclaration.PlayAgeRangeDeclarationPackage.<clinit>(PlayAgeRangeDeclarationPackage.kt:19)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.PackageList.getPackages(PackageList.java:56)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at playagerangedeclaration.example.MainApplication.reactHost_delegate$lambda$1(MainApplication.kt:16)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at playagerangedeclaration.example.MainApplication$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:86)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at playagerangedeclaration.example.MainApplication.getReactHost(MainApplication.kt:12)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.getReactHost(ReactActivityDelegate.java:110)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.lambda$onCreate$1(ReactActivityDelegate.java:151)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.$r8$lambda$EZrOZ49X59cmTptZHsnA-w0BgUc(ReactActivityDelegate.java:0)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.systrace.Systrace.traceSection(Systrace.kt:35)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:133)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:61)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8976)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8933)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4293)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4465)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2854)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:108)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:226)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.os.Looper.loop(Looper.java:328)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:9244)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594)
08-18 19:38:44.358 16955 16955 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
08-18 19:38:44.443 15370 15370 D BufferQueueConsumer: [](id:3c0a00000005,api:0,p:-1,c:15370) connect: controlledByApp=false
08-18 19:38:44.446 15370 15485 E OpenGLRenderer: Unable to match the desired swap behavior.
08-18 19:38:44.447 15370 15485 I BLASTBufferQueue: QoSAllocBuff Successful. Ret 0
08-18 19:38:44.468 15370 15485 I gralloc4: @set_metadata: update dataspace from GM (0x00000000 -> 0x10020000)
08-18 19:38:44.469 15370 15485 D BLASTBufferQueue: [VRI[GoogleDiscoverWindow]#5](f:0,a:1) acquireNextBufferLocked size=720x1612 mFrameNumber=1 applyTransaction=true mTimestamp=39095291861406(auto) mPendingTransactions.size=0 graphicBufferId=66013647339539 transform=0
08-18 19:38:44.544 15370 15370 I cejz : onResume
08-18 19:38:44.549 15370 15370 W dvxf : missing event name
08-18 19:38:44.577 6905 6905 I GoogleInputMethodService: GoogleInputMethodService.onFinishInput():2276
MANDATORY Reproducer
https://github.com/Gautham495/react-native-play-age-range-declaration/tree/rn-87/example
Screenshots and Videos
Hướng dẫn đóng góp
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.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi crash từ ví dụ bắt buộc và so sánh các phiên bản NDK được React Native template và thư viện native sử dụng. Kiểm tra cấu hình Android của template, RNGP và tệp được tham chiếu react-native-builder-bob native-common/android/build.gradle. Được xem là hoàn tất khi xác định được hành vi NDK được hỗ trợ và cập nhật hướng dẫn liên quan của template hoặc thư viện để ví dụ không còn crash do không khớp phiên bản.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, cpp
- Lĩnh vực
- build-system, mobile
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 47/100