Skip to content

[ANDROID] NDK Version Mismatch #58005

Description

@riteshshukla04

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions