eclipse / paho.mqtt.android

MQTT Android
Other
2.92k stars 883 forks source link

java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage #434

Open changanfounder opened 3 years ago

changanfounder commented 3 years ago

Please fill out the form below before submitting, thank you!

_Android API Version Bug Seen on: 17_

_Android Version Bug Seen on: 4.2_

Description of Bug:

MqttWireMessage.java Used StandardCharsets.UTF_8; but StandardCharsets.UTF_8 Added in API level 19(4.4)

Console Log output (if available):

W/dalvikvm( 1543): VFY: unable to resolve static field 2056 (UTF_8) in Ljava/nio/charset/StandardCharsets; D/dalvikvm( 1543): VFY: replacing opcode 0x62 at 0x0000 D/SERIAL_JNI_FM( 1543): SERIAL_read_Native ENTRY. I/SERIAL_HAL_FM( 1543): nRead = 0 D/SERIAL_JNI_FM( 1543): SERIAL_read_Native SUCCESS. W/dalvikvm( 1543): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lorg/eclipse/paho/client/mqttv3/internal/wire/MqttWireMessage; D/AndroidRuntime( 1543): Shutting down VM W/dalvikvm( 1543): threadid=1: thread exiting with uncaught exception (group=0x40fa29a8) E/SNPNS ( 1543): [PushSdkCrashExceptionHandler]>>>Push Service uncaughtException E/SNPNS ( 1543): java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets E/SNPNS ( 1543): at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.(MqttWireMessage.java:52) E/SNPNS ( 1543): at org.eclipse.paho.client.mqttv3.internal.ClientState.(ClientState.java:162) E/SNPNS ( 1543): at org.eclipse.paho.client.mqttv3.internal.ClientComms.(ClientComms.java:108)

VinPin commented 3 years ago

E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.(MqttWireMessage.java:52) at org.eclipse.paho.client.mqttv3.internal.ClientState.(ClientState.java:164) at org.eclipse.paho.client.mqttv3.internal.ClientComms.(ClientComms.java:110) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:594) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:438) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:322) at org.eclipse.paho.android.service.MqttConnection.connect(MqttConnection.java:289) at org.eclipse.paho.android.service.MqttService.connect(MqttService.java:329) at org.eclipse.paho.android.service.MqttAndroidClient.doConnect(MqttAndroidClient.java:467) at org.eclipse.paho.android.service.MqttAndroidClient.access$200(MqttAndroidClient.java:76) at org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection.onServiceConnected(MqttAndroidClient.java:115) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1131) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1148) at android.os.Handler.handleCallback(Handler.java:800) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5392) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method)

I also encountered such a problem. How can I solve it? The problem occurred in Android 4.2 (API 17).

VinPin commented 3 years ago

The problem has been solved. Because the StandardCharsets class is missing, we added it. Create a new package directory and copy the StandardCharsets class, and then run the verification successfully.