Android SDK crashes with Null Pointer if Bluetooth is enabled after app launch

The Estimote Android SDK is throwing a null pointer exception. Are we doing something wrong here, or is this an SDK bug?

Steps to reproduce:

  1. Disable Bluetooth on the phone
  2. Start our app (which starts monitoring a region using Estimote SDK)
  3. Enable Bluetooth. Estimote SDK throws null pointer exception and crashes our app.

Here is the stack trace:

01-15 15:34:00.473 28356-28373/ E/EstimoteSDK: com.estimote.sdk.service.internal.LollipopBluetoothAdapter.stop:194 BluetoothAdapter throws unexpected exception
                                                                 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.flushPendingScanResults(android.bluetooth.le.ScanCallback)' on a null object reference
                                                                     at com.estimote.sdk.service.internal.LollipopBluetoothAdapter.stop(LollipopBluetoothAdapter.java:189)
                                                                     at com.estimote.sdk.service.internal.CycleBluetoothScanner.stop(CycleBluetoothScanner.java:72)
                                                                     at com.estimote.sdk.service.internal.CycleBluetoothScanner$1.run(CycleBluetoothScanner.java:84)
                                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
01-15 15:34:05.507 28356-28373/ E/AndroidRuntime: FATAL EXCEPTION: BeaconServiceThread
                                                                    Process: com.pointy.android, PID: 28356
                                                                    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.startScan(java.util.List, android.bluetooth.le.ScanSettings, android.bluetooth.le.ScanCallback)' on a null object reference
                                                                        at com.estimote.sdk.service.internal.LollipopBluetoothAdapter.start(LollipopBluetoothAdapter.java:179)
                                                                        at com.estimote.sdk.service.internal.CycleBluetoothScanner.start(CycleBluetoothScanner.java:59)
                                                                        at com.estimote.sdk.service.internal.CycleBluetoothScanner$1.run(CycleBluetoothScanner.java:93)
                                                                        at android.os.Handler.handleCallback(Handler.java:739)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.os.HandlerThread.run(HandlerThread.java:61)

Thanks for your report! Can you also let us know the version of the SDK, what device you’re using, and what’s the Android OS version? Should help us reproduce it.

Ah, sorry, should have included that.

SDK version: 0.9.5
Android OS version: 6.0.1 (Build MMB29P)
Devices tested: Nexus 5 and Nexus 5X (both crash)

Thanks for that!

I just got a note from our Android engineers that this one is already fixed and should go out in the upcoming SDK release.

1 Like