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

🐛 Attempt to invoke interface method 'void com.bleplx.adapter.BleAdapter.stopDeviceScan()' on a null object reference

Open scarlettmiss opened this issue 1 year ago • 9 comments

Prerequisites

  • [X] I checked the documentation and FAQ without finding a solution
  • [X] I checked to make sure that this issue has not already been filed

Expected Behavior

The app not to crash and start device scan to be called successfully

Current Behavior

The app is crashig with above error. We havent seen it a lot and we have yet to reproduce on our own. Didn't happen on the v2.x

Library version

3.1.2-rc.0

Device

Galaxy Tab A8,Galaxy S20 FE 5G,Galaxy Tab S6 Lite,Lenovo Tab P11 (2nd Gen),Galaxy Tab A (2016)

Environment info

hermesEnabled:true
react native: "0.72.6"

Steps to reproduce

we have not yet reproduced on our side

Formatted code sample or link to a repository

class BleDeviceLocator {
    private bleManager: BleManager;

    constructor() {
        this.bleManager = new BleManager();
    }

    public startBluetoothScanning(): void {
        this.bleManager.startDeviceScan(null, null, (error: BleError | null, device: BlePlxDevice | null) => {
            .
            .
            .
        });
    }
}

Relevant log output

Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'void com.bleplx.adapter.BleAdapter.stopDeviceScan()' on a null object reference
com.bleplx.BlePlxModule.stopDeviceScan (BlePlxModule.java:222)
java.lang.reflect.Method.invoke (Method.java)
com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
com.facebook.jni.NativeRunnable.run (NativeRunnable.java)
android.os.Handler.handleCallback (Handler.java:790)
android.os.Handler.dispatchMessage (Handler.java:99)
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
android.os.Looper.loop (Looper.java:164)
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
java.lang.Thread.run (Thread.java:764)

Additional information

No response

scarlettmiss avatar Nov 20 '23 10:11 scarlettmiss