Hello,
I got occasional (very rare) Play Store reports of app crash (java.lang.RuntimeException) in two of my apps (dealing with communication with BLE devices) in following function:
My code is based on example BLE 2 - Bluetooth Low Energy:
https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/#content
and I use BLE2 v1.37
Rather then enclosing code in try-catch, I want to know what causes this crash and let user know what is wrong. My idea was it can be caused by trying to read data from device which is no longer connected, but this will not cause this code to crash. I also tried situation where list connectedServices was empty - still no crash. According to reports, crash happens on the line:
I was not able to replicate crash in this functions. Does anyone have any idea, what inputs can cause the fail?
Report:
java.lang.RuntimeException:
1.at anywheresoftware.b4a.objects.BleManager2.getService (BleManager2.java:385)
2.at anywheresoftware.b4a.objects.BleManager2.ReadData2 (BleManager2.java:261)
3.at anywheresoftware.b4a.objects.BleManager2.ReadData (BleManager2.java:251)
4.at [my.package.name].masterblemanager._vvvvvvvvvvvvv2 (masterblemanager.java:68)
5.at [my.package.name].main._btn_readinfo_click (main.java:1305)
6.at java.lang.reflect.Method.invoke (Native Method)
7.at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:196)
8.at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:180)
9.at anywheresoftware.b4a.BA.raiseEvent (BA.java:176)
10.at anywheresoftware.b4a.objects.ViewWrapper$1.onClick (ViewWrapper.java:80)
11.at android.view.View.performClick (View.java:6648)
12.at android.view.View.performClickInternal (View.java:6620)
13.at android.view.View.access$3100 (View.java:787)
14.at android.view.View$PerformClick.run (View.java:26167)
15.at android.os.Handler.handleCallback (Handler.java:891)
16.at android.os.Handler.dispatchMessage (Handler.java:102)
17.at android.os.Looper.loop (Looper.java:207)
18.at android.app.ActivityThread.main (ActivityThread.java:7539)
19.at java.lang.reflect.Method.invoke (Native Method)
20.at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
21.at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)
where in line 4: _vvvvvvvvvvvvv2 = manager.ReadData(s)
Many thanks,
Marek
I got occasional (very rare) Play Store reports of app crash (java.lang.RuntimeException) in two of my apps (dealing with communication with BLE devices) in following function:
B4X:
Public Sub BleReadAllCharacteristics
For Each s As String In connectedServices
manager.ReadData(s)
Next
End Sub
My code is based on example BLE 2 - Bluetooth Low Energy:
https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/#content
and I use BLE2 v1.37
Rather then enclosing code in try-catch, I want to know what causes this crash and let user know what is wrong. My idea was it can be caused by trying to read data from device which is no longer connected, but this will not cause this code to crash. I also tried situation where list connectedServices was empty - still no crash. According to reports, crash happens on the line:
B4X:
manager.ReadData(s)
I was not able to replicate crash in this functions. Does anyone have any idea, what inputs can cause the fail?
Report:
java.lang.RuntimeException:
1.at anywheresoftware.b4a.objects.BleManager2.getService (BleManager2.java:385)
2.at anywheresoftware.b4a.objects.BleManager2.ReadData2 (BleManager2.java:261)
3.at anywheresoftware.b4a.objects.BleManager2.ReadData (BleManager2.java:251)
4.at [my.package.name].masterblemanager._vvvvvvvvvvvvv2 (masterblemanager.java:68)
5.at [my.package.name].main._btn_readinfo_click (main.java:1305)
6.at java.lang.reflect.Method.invoke (Native Method)
7.at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:196)
8.at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:180)
9.at anywheresoftware.b4a.BA.raiseEvent (BA.java:176)
10.at anywheresoftware.b4a.objects.ViewWrapper$1.onClick (ViewWrapper.java:80)
11.at android.view.View.performClick (View.java:6648)
12.at android.view.View.performClickInternal (View.java:6620)
13.at android.view.View.access$3100 (View.java:787)
14.at android.view.View$PerformClick.run (View.java:26167)
15.at android.os.Handler.handleCallback (Handler.java:891)
16.at android.os.Handler.dispatchMessage (Handler.java:102)
17.at android.os.Looper.loop (Looper.java:207)
18.at android.app.ActivityThread.main (ActivityThread.java:7539)
19.at java.lang.reflect.Method.invoke (Native Method)
20.at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
21.at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)
where in line 4: _vvvvvvvvvvvvv2 = manager.ReadData(s)
Many thanks,
Marek