bluetooth_low_energy icon indicating copy to clipboard operation
bluetooth_low_energy copied to clipboard

IllegalStateException on Android

Open ekuleshov opened this issue 7 months ago • 26 comments

The following IllegalStateException on some customer devices reported in Sentry. Can't reproduce this on my own devices. Using bluetooth_low_energy 6.0.2.

It looks like the mBluetoothGattServerCallback may not be set at the time it is called:

https://github.com/yanshouwang/bluetooth_low_energy/blob/78e74f7793312394e6221de89560cd7c9e5791cf/bluetooth_low_energy_android/android/src/main/kotlin/dev/hebei/bluetooth_low_energy_android/MyPeripheralManager.kt#L27-L35

Dart exception:

File "my_api.g.dart", line 1482, in MyPeripheralManagerHostAPI.addService
  File "<asynchronous suspension>"
  File "my_peripheral_manager.dart", line 135, in MyPeripheralManager.addService
  File "<asynchronous suspension>"

Android exception:

PlatformException(IllegalStateException, java.lang.IllegalStateException, Cause: null, Stacktrace: java.lang.IllegalStateException
	at x2.z1.z(MyPeripheralManager.kt:30)
	at x2.z2$a.u(MyAPI.g.kt:30)
	at x2.z2$a.b(Unknown Source:0)
	at x2.n2.a(Unknown Source:2)
	at l3.a$b.a(BasicMessageChannel.java:18)
	at z2.c.l(DartMessenger.java:19)
	at z2.c.m(DartMessenger.java:42)
	at z2.c.i(Unknown Source:0)
	at z2.b.run(Unknown Source:12)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)

ekuleshov avatar Jul 14 '24 16:07 ekuleshov