react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

JNI DETECTED ERROR IN APPLICATION: JNI IsAssignableFrom called with pending exception java.lang.NoSuchMethodError: no non-static method "Lit/innove/BleManager;.setEventEmitterCallback(Lcom/facebook/react/bridge/CxxCallbackImpl;)V

Open mrenann opened this issue 1 year ago • 10 comments

Before open an issue

  • Check the closed issues, your question maybe is not new.
  • We can't debug or reproduce hardware issue.
  • If the library is not working 99% you did something wrong, in the code, installation or in the phone permissions.

Describe the bug when uses the ble-manager crashes the app on android 7

To Reproduce

  1. On android device or emulator with android 7
  2. execute and import some code with react-native-ble-manager
  3. ex:
    BleManager.checkState().then((state) =>
      setEnabledBluetooth(state == 'on')
    );

Expected behavior Crashes the app and dont run

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: Emulator
  • OS: Android 7.0
  • react-native-ble-manager version: 12.1.2
  • react-native version: 0.76.6

Additional context Add any other context about the problem here.

mrenann avatar Jan 14 '25 15:01 mrenann

we are having the same issue with our production app, we received 2 crash reports on firebase from two different devices. OS: Android 8.0 Device 1: Galaxy A5(2017) Device 2: Mate 10 Lite

Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lit/innove/BleManager;.setEventEmitterCallback(Lcom/facebook/react/bridge/CxxCallbackImpl;)V", stack: requireModule@1:132701 get@1:132765 anonymous@1:4437621 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:4429715 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:4429470 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:1393375 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:934127 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:933480 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:740623 loadModuleImplementation@1:107965 guardedLoadModule@1:107488 metroRequire@1:107118 anonymous@1:113851 loadModuleImplementation@1:107965 guardedLoadModule@1:107445 metroRequire@1:107118 global@1:106646

barakataboujreich avatar Jan 16 '25 15:01 barakataboujreich

we are having another crash, i don't know if it is related to the same issue. OS: Android 12.0 Device 1: Galaxy A03 Core Device 2: Moto G Pure (XT2163DL)

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void com.facebook.react.bridge.CxxCallbackImpl.invoke(java.lang.Object[])' on a null object reference
it.innove.NativeBleManagerSpec.emitOnDidUpdateState (NativeBleManagerSpec.java:46)
it.innove.BleManager.checkState (BleManager.java:722)
com.facebook.jni.NativeRunnable.run (NativeRunnable.java)
android.os.Handler.handleCallback (Handler.java:938)

barakataboujreich avatar Jan 16 '25 19:01 barakataboujreich

Are you using the new architecture?

marcosinigaglia avatar Jan 17 '25 08:01 marcosinigaglia

yeah sorry forgot to mention that.

RN version: 0.76.6 new architecture enabled react-native-ble-manager: 12.1.2 on android 8.0 the crash is happening on any device.

on other android versions it is random, we have 10 users crashing on android 11,12 and 13

barakataboujreich avatar Jan 17 '25 09:01 barakataboujreich

I think is a RN problem like https://github.com/facebook/react-native/pull/48606

marcosinigaglia avatar Jan 17 '25 09:01 marcosinigaglia

But this issue is only mentioning API 26 which is android 8. We are facing crashes with android 11, android 12, android 13 and since i last commented we received a crash on android 14. the error in stacktrace is different from the one on android 8. should i open a new issue?

meanwhile this is our discovery: we installed a new RN 0,76,6 new architecture enabled. we generate a debug apk and install it on android 8 device no crash is happening. we generate an apk in release mode, a crash is happening with the error mentioned in this issue

barakataboujreich avatar Jan 17 '25 11:01 barakataboujreich

The issue is in the react-native part so is the more reasonable answer. Try this fix https://github.com/facebook/react-native/issues/48009

marcosinigaglia avatar Jan 17 '25 15:01 marcosinigaglia

I am also having this issue in API version 26. I need help to implement the solution. I can't figure it out xd.

ryd0rz avatar Feb 01 '25 00:02 ryd0rz

Hi, I am facing a similar issue on a specific Android phone:

  • Device: Nokia C21 (Android 11)
  • React Native: 0.78
  • Happens only on the release variant
  • Trigger: Occurs when trying to access a page that imports the library (just importing, nothing else)

I recently updated to the latest React Native version, but the app still crashes. Below is a snippet of the logs right before the crash, showing setEventEmitterCallback on the first line and seemingly some related issues:

runtime.cc:655]   native: #15 pc 00319853  /data/app/~~RYPJSLlNxTAJW8uGYhfJtg==/com.myapp.app-GRtu-YI6gX8_fz2jCTG4Yw==/base.apk!libreactnative.so (offset 1938000) (facebook::react::JavaTurboModule::setEventEmitterCallback(facebook::jni::alias_ref<_jobject*>)+338)
runtime.cc:655]   native: #16 pc 00105627  /data/app/~~RYPJSLlNxTAJW8uGYhfJtg==/com.myapp.app-GRtu-YI6gX8_fz2jCTG4Yw==/base.apk!libappmodules.so (offset 1390000) (facebook::react::NativeBleManagerSpecJSI::NativeBleManagerSpecJSI(facebook::react::JavaTurboModule::InitParams const&)+5706)
runtime.cc:655]   native: #17 pc 00107ab1  /data/app/~~RYPJSLlNxTAJW8uGYhfJtg==/com.<myapp>app-GRtu-YI6gX8_fz2jCTG4Yw==/base.apk!libappmodules.so (offset 1390000) (facebook::react::BleManagerSpec_ModuleProvider(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, facebook::react::JavaTurboModule::InitParams const&)+84)
runtime.cc:655]   native: #18 pc 00120bf3  /data/app/~~RYPJSLlNxTAJW8uGYhfJtg==/com.myapp.app-GRtu-YI6gX8_fz2jCTG4Yw==/base.apk!libappmodules.so (offset 1390000) (facebook::react::autolinking_ModuleProvider(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, facebook::react::JavaTurboModule::InitParams const&)+214)
runtime.cc:655]   native: #19 pc 0015c561  /data/app/~~RYPJSLlNxTAJW8uGYhfJtg==/com.myapp.app-GRtu-YI6gX8_fz2jCTG4Yw==/base.apk!libappmodules.so (offset 1390000) (facebook::react::javaModuleProvider(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, facebook::react::JavaTurboModule::InitParams const&)+128)

A few questions:

  1. Does this issue still persist for others, even after upgrading to React Native 0.78?
  2. Are there any known compatibility issues with specific phones (e.g., Nokia C21)?
  3. Has anyone found a workaround or fix for this (other than the specific fix mentioned above which should be in react-native 0.78)?

Any insights would be greatly appreciated. Thanks!

kh-onsolution avatar Mar 18 '25 06:03 kh-onsolution

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

marcosinigaglia avatar Jun 17 '25 02:06 marcosinigaglia