iBeacon scan error: kotlin.UnitBluetooth Low Energy scan failed with error code: 2


#1

When I open my application and watch log console find this, Is Android SDK has problem?

11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: java.lang.Exception: Bluetooth Low Energy scan failed with error code: 2
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at com.estimote.scanning_sdk.packet_provider.scanner.PostLollipopEstimoteScanner$scan$1$callback$1.onScanFailed(PostLollipopEstimoteScanner.kt:27)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at android.bluetooth.le.BluetoothLeScanner$1.run(BluetoothLeScanner.java:458)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at android.os.Looper.loop(Looper.java:173)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6459)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
11-21 14:40:23.433 31615-31615/com.billy.indoorlocationtest D/Estimote: iBeacon scan error: kotlin.UnitBluetooth Low Energy scan failed with error code: 2
11-21 14:40:23.434 31615-31615/com.billy.indoorlocationtest D/BluetoothAdapter: STATE_ON
11-21 14:40:23.435 31615-31615/com.billy.indoorlocationtest D/BluetoothLeScanner: could not find callback wrapper


#2

Hey @BillyLu

I need more details:

  1. Which SDK version are you using (I assume it’s Indoor Location SDK for Android)
  2. Your phone OS version and model - very important.
  3. Does your app has Location permissions enabled
  4. Does your phone has bluetooth enabled
  5. Does your phone has Location enabled.

Cheers!


#3

Thanks you, I resolved.


#4

Uhm can i know how you resolve it ?


#5

@JML, AFAIK, this error code 2 is actually android.bluetooth.le.ScanCallback's:

SCAN_FAILED_APPLICATION_REGISTRATION_FAILED
Fails to start scan as app cannot be registered.

Not much is known about the reason behind this error, we gather it’s something to do with the BLE stack on some smartphones just acting out. I often get this error on my Nexus 5X for example, a device that’s known for it’s problematic BLE stack. Restarting Bluetooth helps in my case.


#6

Hello,

Im using SDK minVersion 21 and compile version 27. Im testing it on Huawei P9 Lite (real phone connecting by USB port).My phone has bluetooth and location enabled.

Can you help me please? Do you have any idea where is the problem, please? :)))

Thank you.


#7

So actually, I’ve been working a bit with the Android Bluetooth stack since my last post in this topic, and I found out that the BLE error code 2 often means there’s no more slots available in the system’s Bluetooth service for the app to start scanning.

This usually happens in development, where you often re-deploy apps, terminate them, re-deploy, terminate, etc., since apparently when an app gets force-stopped, it doesn’t always unregister from the Bluetooth service. (At least that was the case for me.) The solution is still to simply restart Bluetooth.

In production apps, I think this should be much less of a problem, assuming you properly stop Bluetooth scans in the onDestroy/onStop lifecycle callbacks, etc.


#8

I use generally SDK minVersion 21 and compile version 27. Is there any problem with that.