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 not scanning for devices

See original GitHub issue

I tried to run the code with SDK version 25 and Build tool version 25.0.3. Have got the error as below.

06-20 17:25:45.382 29678-29678/com.example.android.bluetoothlegatt D/BluetoothAdapter: startLeScan(): null
06-20 17:25:45.385 29678-29678/com.example.android.bluetoothlegatt D/BluetoothAdapter: STATE_ON
06-20 17:25:45.395 29678-29692/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
06-20 17:25:45.400 29678-29692/com.example.android.bluetoothlegatt W/Binder: Caught a RuntimeException from the binder stub implementation.
                                                                             java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
                                                                                 at android.os.Parcel.readException(Parcel.java:1620)
                                                                                 at android.os.Parcel.readException(Parcel.java:1573)
                                                                                 at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:772)
                                                                                 at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:324)
                                                                                 at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56)
                                                                                 at android.os.Binder.execTransact(Binder.java:453)
06-20 17:25:47.404 29678-29879/com.example.android.bluetoothlegatt D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-20 17:25:47.442 29678-29879/com.example.android.bluetoothlegatt I/Adreno: QUALCOMM build                   : 166ada0, Ifd751822f5
                                                                             Build Date                       : 01/26/16
                                                                             OpenGL ES Shader Compiler Version: XE031.06.00.05
                                                                             Local Branch                     : AU12_SBA
                                                                             Remote Branch                    : 
                                                                             Remote Branch                    : 
                                                                             Reconstruct Branch               : 
06-20 17:25:47.454 29678-29879/com.example.android.bluetoothlegatt I/OpenGLRenderer: Initialized EGL, version 1.4
06-20 17:25:55.381 29678-29678/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()

Have got it resolved by adding the following permissions in the manifest.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
hemapanjakshramcommented, Jul 17, 2017
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> By adding this above code also not working
0reactions
SZooocommented, Oct 20, 2022

You need the location permission to scan for devices. If you are on API 23+, make sure you request permission as I mentioned in googlearchive/android-BluetoothLeGatt#38 comment 2

Why not commit the code

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Unable to scan or discover BT and BLE devices in android
Unable to scan or discover BT and BLE devices in android · 1. First off I have added my permissions under AndroidManifest ·...
Read more >
No devices found during BLE scan on android 10
Starting with Android 10, apps that do BLE scanning need to request fine location permission, otherwise no results will be returned. If you...
Read more >
Not able to scan bluetooth devices - Microsoft Community
I am not able to connect with bluetooth devices. Bluetooth is installed in my system however it is not working.
Read more >
cannot begin scanning for ble devices · Issue #53 - GitHub
Currently on On a mac running nRF connect 2.0.0 BLE App and the start scanning is disabled. i've got a nordic board that...
Read more >
Scanning BLE devices - BLE Networking Guide
This function makes a scan to discover a specific BLE device by its MAC address. This function is used to know if a...
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