question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BLE Permission not working on 0.63.2 with Android 10

See original GitHub issue

Hello there,

My project was on React Native 0.63.2 version and when I tried to scan ble devices couldn’t see any of them. Even I asking permission and allow the location. It happens only Android 10 devices. When I check the error callback it says: [BleError: Device is not authorized to use BluetoothLE]
This error not happens on 0.62.2

Interesting things are:

  • When I ask permission on Android 10, it’s not ask “Allow Always”, only “Allow While Using” and “Deny”
  • When I go to Settings => Apps => <My App> => Permissions => Location section and I select “Deny” and “Allow While Using” again, the error disappears and app can search devices properly.

Buggy versions:

    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-ble-plx": "^2.0.1"

Working versions:

    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-ble-plx": "^2.0.1"

AndroidManifest.xml permissions

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.BLUETOOTH"/>
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

It may not happens because of this package, maybe React Native itself but I found it on this package.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16

github_iconTop GitHub Comments

40reactions
owavcommented, Aug 27, 2020

Hi,

I had the same issue when I updated my targetSdkVersion from 28 to 29.

Replacing the android permission ACCESS_COARSE_LOCATION with ACCESS_FINE_LOCATION in my AndroidManifest.xml and in my app’s code for manually asking the user with PermissionAndroid fixed it for me.

Recap of what’s working for me : build.gradle :

buildToolsVersion = "29.0.2" 
minSdkVersion = 18 
compileSdkVersion = 29 
targetSdkVersion = 29 

AndroidManifest.xml :

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

in my app’s code :

const granted = await PermissionsAndroid.request(
	PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
	{
		title: 'Permission Localisation Bluetooth',
		message: 'Requirement for Bluetooth'
		buttonNeutral: 'Later',
		buttonNegative: 'Cancel',
		buttonPositive: 'OK',
	}
);

Hope this helps.

7reactions
Xenofonocommented, Dec 2, 2020

I struggled with this issue for about 6 hours, nothing worked. Then I restarted my phone and it worked immediately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BLE Permission not working on 0.63.2 with Android 10 #730
Hello there,. My project was on React Native 0.63.2 version and when I tried to scan ble devices couldn't see any of them....
Read more >
Bluetooth permissions - Android Developers
To use Bluetooth features in your app, you must declare several permissions. You should also specify whether your app requires support for Bluetooth...
Read more >
Android 10 not working with BLE Bluetooth scanning
To make BLE scanning work on Android apps targeting Android 10 you need ... Android 10 introduces the ACCESS_BACKGROUND_LOCATION permission.
Read more >
react-native-ble-manager - npm
A BLE module for react native.. Latest version: 8.5.0, last published: 20 days ago. Start using react-native-ble-manager in your project by ...
Read more >
Android permissions - BLE - Android 12 - MIT App Inventor Help
The BluetoothLE extension has not yet been updated to support Android 12. As a workaround, you can add the BluetoothClient component to your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found