清泛IT社区

标题: BLE UUID是对的但连接闪退:java.lang.IllegalArgumentException: UUID string too large [打印本页]

作者: App Inventor 2     时间: 2024-09-21 12:00
标题: BLE UUID是对的但连接闪退:java.lang.IllegalArgumentException: UUID string too large
请问UUID是对的 连接闪退,
下面是报错日志
java.lang.ExceptionInInitializerError
at edu.mit.appinventor.ble.BluetoothLEint$BLEReadOperation.subscribe(BluetoothLEint.java:357)
at edu.mit.appinventor.ble.BluetoothLEint$BLEReadOperation.run(BluetoothLEint.java:325)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:224)
at android.os.Looper.loop(Looper.java:318)
at android.app.ActivityThread.main(ActivityThread.java:8790)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.IllegalArgumentException: UUID string too large
at java.util.UUID.fromStringJava11(UUID.java:238)
at java.util.UUID.fromString(UUID.java:226)
at edu.mit.appinventor.ble.BluetoothLEGattAttributes.<clinit>(BluetoothLEGattAttributes.java:33)
... 10 more

----------------

经过调查,问题出在如下报错中的“uuid string too large”上,java内置的UUID中的函数。
通过调查发现是由于ble拓展编译平台(java8),和目前appinventor with sdk34 平台(java11) 对这个函数的处理不兼容导致的。
这似乎是由于 Java 8 和 11 之间围绕 UUID 的语义变化导致的,该变化从 Android 14 开始生效。
Thanks for the report. This appears to be due to a semantic change between Java 8 and 11 around UUIDs that went into affect starting with Android 14. I'll look at updating the BLE extension to be more robust to the Java 11 constraints.

来源:https://community.appinventor.mi ... android-14/124432/3


因此使用java11 编译出来的ble拓展即可解决这个问题,请使用最新编译出来的拓展(版本
20240822):https://www.fun123.cn/reference/iot/bluetoothle.html








欢迎光临 清泛IT社区 (https://bbs.tsingfun.com/) Powered by Discuz! X3.3