react-native-ble-manager: null is not an object (evaluating 'bleManager.start')

Version

Tell us which versions you are using:

  • react-native-ble-manager v7.3.1
  • expo v38.0.8
  • Android v8.1

Expected behaviour

bleManager.start() should initialize the BLE module

Actual behaviour

throws error: null is not an object (evaluating ‘bleManager.start’)

Steps to reproduce

  1. Create a new project with expo
  2. npm i react-native-ble-manager
  3. Insert following in the main app.js file: useEffect(() => { bleManager.start().then(() => console.log('BLE Module Initialized')).catch(err => console.log(err)) }, [])

Stack trace and console log

null is not an object (evaluating 'bleManager.start')
* http://192.168.1.103:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:134291:20 in <unknown>
- node_modules/promise/setimmediate/core.js:45:6 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:22 in doResolve
- node_modules/promise/setimmediate/core.js:66:11 in Promise
* http://192.168.1.103:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:134286:26 in start
* App.js:11:12 in useEffect$argument_0
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18008:31 in commitHookEffectList
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18061:28 in commitPassiveHookEffects
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:286:4 in invokeGuardedCallbackImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:497:2 in invokeGuardedCallback
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21577:27 in flushPassiveEffectsImpl
- node_modules/scheduler/cjs/scheduler.development.js:818:23 in unstable_runWithPriority
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20435:23 in performSyncWorkOnRoot
* [native code]:null in performSyncWorkOnRoot
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5703:31 in runWithPriority$argument_1
- node_modules/scheduler/cjs/scheduler.development.js:818:23 in unstable_runWithPriority
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5698:21 in flushSyncCallbackQueueImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5686:28 in flushSyncCallbackQueue
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19845:30 in scheduleUpdateOnFiber
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:23608:14 in updateContainer
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:24593:19 in ReactNativeRenderer.render
- node_modules/react-native/Libraries/ReactNative/renderApplication.js:54:4 in renderApplication
- node_modules/react-native/Libraries/ReactNative/AppRegistry.js:117:25 in runnables.appKey.run
- node_modules/react-native/Libraries/ReactNative/AppRegistry.js:213:4 in runApplication
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:425:19 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:373:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (2 by maintainers)

Most upvoted comments

@maskaravivek do you have any advice on how to make this work? Ive gone through the install process three times and still have had no luck. after each attempt I deleted package.json & node_modules/

  1. expo eject
  2. npm i --save react-native-ble-manager
  3. update android manifest & ios plist
  4. ran pod install in the ios directory

even though the library supports auto-linking for my second attempt I ran react-native link react-native-ble-manager.

EDIT: I ended up creating a new branch and rerunning the expo eject steps everything seems to be working now.

have you added the ble_manager to your pod file and ran pod install

pod ‘react-native-ble-manager’, :path => ‘…/node_modules/react-native-ble-manager’

I can only find the following bleManager object when I console.log my import:

bleManager {
  "isPeripheralConnected": [Function bound isPeripheralConnected],
}