hivemq-mqtt-client: NoClassDefFoundError in Android 5-6 when built in Android Studio 4.2.1
Expected behavior
MQTT Client can init and connect with Android 5-6 devices
Actual behavior
The client is crashing in Android 5 and Android 6 with
java.lang.NoClassDefFoundError: com.hivemq.client.internal.mqtt.-$$Lambda$QT9XFB_2yV951PYVP80Cqx3qU9Q
at com.hivemq.client.internal.mqtt.MqttRxClientBuilderBase.automaticReconnect(MqttRxClientBuilderBase.java:156)
at com.hivemq.client.internal.mqtt.mqtt3.Mqtt3RxClientViewBuilder.automaticReconnect(Mqtt3RxClientViewBuilder.java:38)
at com.mypackage.MqttHiveClient.<init>(MqttHiveClient.java:54)
No issues with newer Android versions or when built in Android Studio 4.1.x
To Reproduce
Run the app with following code
Reproducer code
Mqtt3ClientBuilder mqtt3ClientBuilder = Mqtt3Client.builder()
.identifier(identifier)
.serverHost(host)
.serverPort(port)
.simpleAuth(Mqtt3SimpleAuth.builder()
.username(username)
.password(password.getBytes())
.build())
.automaticReconnect()
.initialDelay(10, TimeUnit.SECONDS)
.maxDelay(60, TimeUnit.SECONDS)
.applyAutomaticReconnect();
dependencies:
implementation 'com.hivemq:hivemq-mqtt-client:1.2.2'
implementation 'com.hivemq:hivemq-mqtt-client-websocket:1.2.2'
implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.3'
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.3'
buildscript/dependencies:
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'gradle.plugin.com.github.sgtsilvio.gradle:android-retrofix:0.3.6'
apply plugin: 'com.github.sgtsilvio.gradle.android-retrofix'
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 15 (5 by maintainers)
I tried to build with the old Gradle and Gradle Plugin and it works for Android 5 then.
A fix for the latest Android Studio 4.2.1 would be great.
@aloz77 @digrec @volkansahin45 @george-theocharis @codefluencer @HarisHoulis the new 0.4.0 release of android-retroffix (https://github.com/SgtSilvio/android-retrofix/releases/tag/v0.4.0) should work with Android Gradle Plugin 4.x and 7.x Please comment if it works now.