react / react/react-native

[ANDROID] NDK Version Mismatch

未关闭
#58,005 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Needs: Author Feedback Needs: Repro Platform: Android Stale
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

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
Image

When I specifically define NDK 27 in android/build.gradle of my library . The issue is fixed

Image

I can see two solutions for this

  1. 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
  2. Upgrading app template and RNGP to use 28.x.x
Steps to reproduce
  1. Install the Repro
  2. Run the example app
  3. It will crash
  1. 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
Image

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先复现必需示例中的崩溃,并比较 React Native template 和原生库所使用的 NDK 版本。检查模板的 Android 配置、RNGP,以及所引用的 react-native-builder-bob native-common/android/build.gradle。完成的标准是确定受支持的 NDK 行为,并更新相关的模板或库指南,使示例不再因版本不匹配而崩溃。

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

评估

技术栈
android, cpp
领域
build-system, mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
47/100

把新 issue 发到你的邮箱

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