NullPointerxceptoin in library?



  • I'm trying to fix the BLE issues in an app which heavily relies on Bluetooth, I've implemented the Sweetblue library, which is already a big improvement. However, a lot of people in my Internal Test and Alpha tracks are experiencing issues (Especially Motorola and Huawei users)… From the Play Console I find this stack trace to be the culprit:

    The biggest issue her is that I cannot reproduce it with my own phone, nor with the development phones that I have... Does anybody have any clue?

    java.lang.NullPointerException:
    at com.idevicesinc.sweetblue.internal.P_BleDeviceImpl.addWriteTasks (Unknown Source:20)
    at com.idevicesinc.sweetblue.internal.P_BleDeviceImpl.write_internal (Unknown Source:106)
    at com.idevicesinc.sweetblue.internal.P_BleDeviceImpl.write (Unknown Source)
    at com.idevicesinc.sweetblue.BleDevice.write (Unknown Source:2)
    at com....Invers.CloudBoxx.writeCommand (CloudBoxx.java:199)
    at com.
    .
    ..Invers.CloudBoxx.unlock (CloudBoxx.java:117)
    at com.
    .
    ..ActivityMain2.requestBLEUnlock (ActivityMain2.java:378)
    at com.
    .
    ..fragments.FragmentCurrent2.lockUnlockButtonPress (FragmentCurrent2.java:447)
    at com.
    .
    ..fragments.FragmentCurrent2.lambda$onViewCreated$4 (FragmentCurrent2.java:176)
    at com.
    .
    .******.fragments.-$$Lambda$FragmentCurrent2$F9cFy2mt3ExdgeY0E0RxslsFYZs.onClick (Unknown Source:2)
    at android.view.View.performClick (View.java:6653)
    at android.view.View.performClickInternal (View.java:6625)
    at android.view.View.access$3100 (View.java:786)
    at android.view.View$PerformClick.run (View.java:26223)
    at android.os.Handler.handleCallback (Handler.java:891)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:207)
    at android.app.ActivityThread.main (ActivityThread.java:7470)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)



  • Unfortunately those line numbers are WAY off. If you're using proguard, please add these lines to your proguard file:

    -keep class com.idevicesinc.sweetblue.**                                    { *; }
    -keepattributes SourceFile,LineNumberTable,Signature,*Annotation*,EnclosingMethod
    -dontwarn com.idevicesinc.sweetblue.**