facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.04k stars 24.32k forks source link

EarlyJsError: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary #47352

Open auliakbarh opened 17 hours ago

auliakbarh commented 17 hours ago

Description

I'm using "react-native": "0.76.0", and I tried to implement ndk but I got an error:

EarlyJsError: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary

image

I need to secure my env since in react-native-config mentioned Keep in mind this module doesn't obfuscate or encrypt secrets for packaging, so do not store sensitive keys in .env

in android/app/build.gradle:

android {
  ...
  externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
            version '3.22.1'
        }
    }
  ...
}

That lines causing the error, but when I remove those lines I can't use the secrets.

can anyone help me?

Steps to reproduce

Try to implement these:

React Native Version

0.76.0

Affected Platforms

Runtime - Android

Areas

TurboModule - The New Native Module System

Output of npx react-native info

System:
  OS: macOS 15.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 125.73 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.16.0
    path: ~/.nvm/versions/node/v20.16.0/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.1
    path: ~/.nvm/versions/node/v20.16.0/bin/npm
  Watchman:
    version: 2024.10.28.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/auliakbarh/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK:
    API Levels:
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.7.4
    path: /Users/auliakbarh/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0-alpha.2
    wanted: 15.0.0-alpha.2
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.0
    wanted: 0.76.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

Exception in native call from JS
                                                                                                    com.facebook.react.common.JavascriptException: EarlyJsError: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary., stack:
                                                                                                    invariant@2040:26
                                                                                                    getEnforcing@2665:28
                                                                                                    anonymous@356569:68
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@356545:76
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@356504:75
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@22336:53
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@25358:51
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@25344:200
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@175:38
                                                                                                    metroRequire@89:92
                                                                                                    anonymous@20594:14
                                                                                                    loadModuleImplementation@267:14
                                                                                                    guardedLoadModule@168:47
                                                                                                    metroRequire@89:92
                                                                                                    global@359111:4

                                                                                                        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.kt:52)
                                                                                                        at com.facebook.react.runtime.ReactInstance$ReactJsExceptionHandlerImpl.reportJsException(ReactInstance.java:336)
                                                                                                        at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                        at android.os.Looper.loop(Looper.java:317)
                                                                                                        at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
                                                                                                        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)

Reproducer

https://github.com/auliakbarh/reproduce-error-turbomodule-rn-using-cmake

Screenshots and Videos

image

react-native-bot commented 17 hours ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.1. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
react-native-bot commented 17 hours ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
goguda commented 9 hours ago

We're getting this too since upgrading to 0.76 in production on specific phones, mostly Android 14. Haven't been able to reproduce in development:

Thread terminating due to uncaught exception of type facebook::jni::JniException: com.facebook.react.common.JavascriptException: EarlyJsError: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary., stack:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 11864 >>> com.iroomit.iroomitapp <<<

backtrace:
  #00  pc 0x00000000000927e8  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
  #01  pc 0x000000000009dd84  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libc++_shared.so (BuildId: 982d68842b3bd6a164609be09a533324b1f28526)
  #02  pc 0x000000000009ca44  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libc++_shared.so (BuildId: 982d68842b3bd6a164609be09a533324b1f28526)
  #03  pc 0x000000000009ced4  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libc++_shared.so (BuildId: 982d68842b3bd6a164609be09a533324b1f28526)
  #04  pc 0x000000000009ce74  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libc++_shared.so (std::terminate()+56) (BuildId: 982d68842b3bd6a164609be09a533324b1f28526)
  #05  pc 0x0000000000345624  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #06  pc 0x0000000000540408  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #07  pc 0x000000000039af84  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (facebook::react::JsErrorHandler::handleFatalError(facebook::jsi::Runtime&, facebook::jsi::JSError&)+5544) (BuildId: 1418e94c42deb385)
  #08  pc 0x0000000000350114  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #09  pc 0x00000000000bb7f0  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #10  pc 0x00000000000bb450  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #11  pc 0x00000000000c2528  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #12  pc 0x00000000000d2874  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #13  pc 0x00000000000d4224  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #14  pc 0x00000000000d38e0  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #15  pc 0x0000000000106cb4  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #16  pc 0x00000000000ae924  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #17  pc 0x00000000000ae7ac  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (facebook::hermes::HermesRuntime::evaluateJavaScriptWithSourceMap(std::__ndk1::shared_ptr<facebook::jsi::Buffer const> const&, std::__ndk1::shared_ptr<facebook::jsi::Buffer const> const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+100) (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #18  pc 0x00000000000af7c8  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libhermes.so (BuildId: b0f589a6e8d91abac4ce7ed08803646a812a4f49)
  #19  pc 0x000000000034c224  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #20  pc 0x00000000004dc138  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #21  pc 0x0000000000349e28  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #22  pc 0x000000000051b7b4  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libreactnative.so (BuildId: 1418e94c42deb385)
  #23  pc 0x0000000000019804  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libfbjni.so (facebook::jni::detail::MethodWrapper<void (facebook::jni::JNativeRunnable::*)(), &(facebook::jni::JNativeRunnable::run()), facebook::jni::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject*>)+72) (BuildId: a22242831a7971267de570e06121acb588ce64cd)
  #24  pc 0x0000000000019744  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/split_config.arm64_v8a.apk!libfbjni.so (facebook::jni::detail::FunctionWrapper<void (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject*>), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject*, void>::call(_JNIEnv*, _jobject*, void (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject*>))+60) (BuildId: a22242831a7971267de570e06121acb588ce64cd)
  #25  pc 0x00000000003343c0  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+112)
  #26  pc 0x0000000000971514  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.Handler.dispatchMessage+68)
  #27  pc 0x000000000077f820  /apex/com.android.art/lib64/libart.so (nterp_helper+4016)
  #28  pc 0x000000000024c1fc  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/base.apk (com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage)
  #29  pc 0x0000000000974ed4  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.Looper.loopOnce+980)
  #30  pc 0x0000000000974a64  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.Looper.loop+916)
  #31  pc 0x000000000077e908  /apex/com.android.art/lib64/libart.so (nterp_helper+152)
  #32  pc 0x000000000024c722  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/base.apk (com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2+70)
  #33  pc 0x000000000077e908  /apex/com.android.art/lib64/libart.so (nterp_helper+152)
  #34  pc 0x000000000024c528  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/base.apk (com.facebook.react.bridge.queue.MessageQueueThreadImpl.b)
  #35  pc 0x000000000077e908  /apex/com.android.art/lib64/libart.so (nterp_helper+152)
  #36  pc 0x00000000002ece40  /data/app/~~Ma_iqwSnCAWnGFXBm5aSeg==/com.iroomit.iroomitapp-6tfaOSi7OQ5KBpu0nbNxjw==/base.apk (com.microsoft.clarity.I5.b.run+4)
  #37  pc 0x000000000040f510  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.lang.Thread.run+64)
  #38  pc 0x0000000000362774  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
  #39  pc 0x000000000034def0  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+132)
  #40  pc 0x0000000000943e28  /apex/com.android.art/lib64/libart.so (art::detail::ShortyTraits<(char)86>::Type art::ArtMethod::InvokeInstance<(char)86>(art::Thread*, art::ObjPtr<art::mirror::Object>, art::detail::ShortyTraits<>::Type...)+60)
  #41  pc 0x000000000063ebd4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1344)
  #42  pc 0x000000000063e684  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallbackWithUffdGc(void*)+8)
  #43  pc 0x00000000000f74f8  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
  #44  pc 0x0000000000094020  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

New architecture is disabled for us.