SimpleBle
SimpleBle copied to clipboard
App Crashes on Read and Write
Hi,
I've successfully built the app and run it on a Samsung S8.
When I press 'SCAN BLE' it correctly identifies local BLE devices.
But when I press either 'WRITE BLE' or 'READ BLE' it crashes immediately.
Below is the Logcat - which includes some of my debugging statements. I'd be gratefl for any suggestions as to what I'm doing wrong.
Many Thanks Kirby
17:30:36.994 6735-6762/com.ederdoski.appexample I/TAG: PKJ: connected to GATT server ... 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: btnRead.setOnClickListener: call ble.read ... 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: ... Constants.SERVICE_COLLAR_INFO: BED9865E-81B1-471C-BF0E-6C2C135F2D0E 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: ... Constants.CHARACTERISTIC_CURRENT_POSITION: 4D79B459-F1BA-4B27-9A32-CDF54391E28A 17:30:46.314 6735-6735/com.ederdoski.appexample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ederdoski.appexample, PID: 6735 java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference at com.ederdoski.simpleble.utils.BluetoothLEHelper.read(BluetoothLEHelper.java:152) at com.ederdoski.appexample.MainActivity.lambda$listenerButtons$4$MainActivity(MainActivity.java:210) at com.ederdoski.appexample.-$$Lambda$MainActivity$KdlyIYg8HZKdZNucwrjMMAU0rfs.onClick(Unknown Source:2) at android.view.View.performClick(View.java:7352)
same problem
@KirbyJames did you fix this problem?
same problem
use other libraries, this library is not stable, and write and read ble aren't working at all
My guess is that you need to pass the appropriate SERVICE and CHARACTERISTICS strings to the read and write methods, that's why it's crashing. At least that was my case. I think the library is not that bad, you just need to make sure you're passing the right data.
Hi,
I've successfully built the app and run it on a Samsung S8.
When I press 'SCAN BLE' it correctly identifies local BLE devices.
But when I press either 'WRITE BLE' or 'READ BLE' it crashes immediately.
Below is the Logcat - which includes some of my debugging statements. I'd be gratefl for any suggestions as to what I'm doing wrong.
Many Thanks Kirby
17:30:36.994 6735-6762/com.ederdoski.appexample I/TAG: PKJ: connected to GATT server ... 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: btnRead.setOnClickListener: call ble.read ... 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: ... Constants.SERVICE_COLLAR_INFO: BED9865E-81B1-471C-BF0E-6C2C135F2D0E 17:30:46.310 6735-6735/com.ederdoski.appexample I/TAG: PKJ: ... Constants.CHARACTERISTIC_CURRENT_POSITION: 4D79B459-F1BA-4B27-9A32-CDF54391E28A 17:30:46.314 6735-6735/com.ederdoski.appexample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ederdoski.appexample, PID: 6735 java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference at com.ederdoski.simpleble.utils.BluetoothLEHelper.read(BluetoothLEHelper.java:152) at com.ederdoski.appexample.MainActivity.lambda$listenerButtons$4$MainActivity(MainActivity.java:210) at com.ederdoski.appexample.-$$Lambda$MainActivity$KdlyIYg8HZKdZNucwrjMMAU0rfs.onClick(Unknown Source:2) at android.view.View.performClick(View.java:7352)
i'm sorry for the late reply, hope what this response can help other developers, you dont are sending the parameters correctly.
effectively the library is crash but the log indicate the problem just here : android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference
you are dont send the Characteristic correctly.
Make sure you have a correctly number of SERVICE and CHARACTERISTIC
sorry for the problems, i am working on an update for this problem soon
Hi, have you been able to fix the problem ?
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ederdoski.appexample, PID: 13677 java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference at com.ederdoski.simpleble.utils.BluetoothLEHelper.write(BluetoothLEHelper.java:135) at com.ederdoski.appexample.MainActivity.lambda$listenerButtons$5$MainActivity(MainActivity.java:186)
when I press either 'WRITE BLE' or 'READ BLE' it crashes immediately.
Sorry i dont have new updates over this issue, but the solution has previously written