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.
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? :)))
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.
Could you try disabling additional features when building your ProximityObserver object? There are two of them enabled by default - Telemetry scanning, and Estimote Secure Monitoring.