Answer the question
In order to leave comments, you need to log in
How to fix the error: null is not an object (evaluation of 'bleManager.start')?
I use the react-native-ble-manager library to connect an Android phone to a BLE device, but when I call the BleManager.start() method, an error immediately pops up, I tried to look for a solution on GitHub for this library in the Issues section, but nothing helps from proposed, they often write that the library is not installed correctly, I have already double-checked and reinstalled everything 10 times. Here are my installation steps:
npm i --save react-native-ble-manager
// file: android/app/src/main/AndroidManifest.xml
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
...
ACCESS_FINE_LOCATION
both ACCESS_COARSE_LOCATION
, both together and separately.npm i
react-native link && react-native link react-native-ble-manager
...
import BleManager from 'react-native-ble-manager';
...
const scanAndConnect = () => {
BleManager.start()
.catch((err) => {
console.error(err);
});
};
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
Answer the question
In order to leave comments, you need to log in
The problem was that targetSdkVersion
for Android 9.0 it should be 28 and not 29 in the filebuild.gradle
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question