paho.mqtt.java icon indicating copy to clipboard operation
paho.mqtt.java copied to clipboard

java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets Crash

Open ouyangshengduo opened this issue 6 years ago • 5 comments

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

ouyangshengduo avatar May 23 '19 06:05 ouyangshengduo

the same issue

dtboy1995 avatar Jul 25 '19 02:07 dtboy1995

@ouyangshengduo hello i test the lib https://github.com/eclipse/paho.mqtt.android on Android 4.3 it works well

dtboy1995 avatar Jul 29 '19 05:07 dtboy1995

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 avatar Jul 31 '19 11:07 castasat

@castasat hello bro,please use MqttAndroidClient, i guess you not use the class, could you paste your code?

dtboy1995 avatar Jul 31 '19 11:07 dtboy1995

Im using MqttAndroidClient and I have the same problem, the problem arise after version 1.2.0

Devofure avatar Apr 14 '21 12:04 Devofure