react / react/react-native

[ANDROID] NDK Version Mismatch

クローズ
#58,005 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Author Feedback Needs: Repro Platform: Android Stale
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. 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 を短くまとめたダイジェスト。