dotintent / react-native-ble-plx

React Native BLE library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› com.bleplx.BlePlxModule.state java.lang.NullPointerException

jsp1024 opened this issue Β· comments

Prerequisites

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

Expected Behavior

The issue seems to occur when trying to startDeviceScan with useEffect when navigating from the webview screen to the native screen.

Current Behavior

Exception java.lang.NullPointerException:
at com.bleplx.BlePlxModule.state (BlePlxModule.java)
at java.lang.reflect.Method.invoke
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java)
at com.facebook.react.bridge.JavaModuleWrapper.invoke
at com.facebook.jni.NativeRunnable.run
at android.os.Handler.handleCallback (Handler.java:958)
at android.os.Handler.dispatchMessage (Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run
at java.lang.Thread.run (Thread.java:1012)

Library version

"react-native-ble-plx": "3.1.2", "react-native-webview": "13.6.3"

Device

android all device, sdk version

Environment info

System:
  OS: macOS 14.2
  CPU: (8) x64 Apple M1 Pro
  Memory: 26.74 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 16.13.2
    path: ~/.nvm/versions/node/v16.13.2/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v16.13.2/bin/yarn
  npm:
    version: 9.5.0
    path: ~/.nvm/versions/node/v16.13.2/bin/npm
  Watchman:
    version: 2023.08.07.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
    System Images:
      - android-30 | Google Play ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.0/15A240d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

  1. …
  2. …

Formatted code sample or link to a repository

.

Relevant log output

.

Additional information

We are not experiencing any issues in our test environment, but we are seeing this issue in apps that are deployed to the playstore.

The issue seems to occur when trying to startDeviceScan with useEffect when navigating from the webview screen to the native screen.

The important thing is that I have no idea where the error you're seeing in the logs is coming from, and it's not happening in my test environment.

The issue was caused by the ble scan action happening at the same time as the page was mounted, and I fixed it by making the scan action happen a certain amount of time after the page was mounted. I'm writing this down in case anyone else has the same issue.