SimpleBle icon indicating copy to clipboard operation
SimpleBle copied to clipboard

App Crashes on Read and Write

Open KirbyJames opened this issue 5 years ago • 11 comments

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)

KirbyJames avatar May 06 '19 16:05 KirbyJames

same problem

rdonik avatar Jun 21 '19 20:06 rdonik

@KirbyJames did you fix this problem?

rdonik avatar Jun 21 '19 20:06 rdonik

same problem

zadShaikh avatar Jul 18 '19 09:07 zadShaikh

use other libraries, this library is not stable, and write and read ble aren't working at all

rdonik avatar Jul 18 '19 09:07 rdonik

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.

kmare avatar Nov 03 '19 20:11 kmare

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.

ederdoski avatar Apr 20 '20 19:04 ederdoski

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

ederdoski avatar Apr 20 '20 19:04 ederdoski

Hi, have you been able to fix the problem ?

plucchetti avatar Apr 22 '21 19:04 plucchetti

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)

plucchetti avatar Apr 22 '21 19:04 plucchetti

when I press either 'WRITE BLE' or 'READ BLE' it crashes immediately.

plucchetti avatar Apr 22 '21 19:04 plucchetti

Sorry i dont have new updates over this issue, but the solution has previously written

EderDominguez avatar Apr 26 '21 17:04 EderDominguez