java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets Crash
Please fill out the form below before submitting, thank you!
- [ ] Bug exists Release Version 1.2.0 ( Master Branch)
- [x] Bug exists in MQTTv3 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)
If this is a bug regarding the Android Service, please raise the bug here instead: https://github.com/eclipse/paho.mqtt.android/issues/new
When I use Android 4.1, Paho Mqtt Client's version is 1.2.1, crash
I see org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage have these code:
protected static final Charset STRING_ENCODING = StandardCharsets.UTF_8;
I find the StandardCharsets support min Android API is 19 (Android 4.4), so how to solve this problem when i use Paho Mqtt Version 1.2.1 and Android 's version is Android 4.0 or up
the same issue
@ouyangshengduo hello i test the lib https://github.com/eclipse/paho.mqtt.android on Android 4.3 it works well
Encountered the same error while using these dependencies in my build.gradle:
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.1'
implementation("org.eclipse.paho:org.eclipse.paho.android.service:1.1.1")
Here is the stacktrace:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.<clinit>(MqttWireMessage.java:52)
at org.eclipse.paho.client.mqttv3.internal.ClientState.<init>(ClientState.java:162)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.<init>(ClientComms.java:108)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:470)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:320)
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:1111)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1128)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(NativeStart.java)
and the phone was:
Samsung Galaxy S3 Android 4.3 armeabi-v7a Exynos 4412 OpenGL ES 2.0
@castasat hello bro,please use MqttAndroidClient, i guess you not use the class, could you paste your code?
Im using MqttAndroidClient and I have the same problem, the problem arise after version 1.2.0