Closed aloz77 closed 2 years ago
Hi @aloz77 did you set the Java version to 1.8, so that lambdas are properly desugared?
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
(https://hivemq.github.io/hivemq-mqtt-client/docs/installation/android/)
Yes, of cause, JavaVersion.VERSION_1_8
is enabled as in your snippet above.
The issue was introduced by Android 4.2 IMHO.
Did you set?
android {
compileOptions {
coreLibraryDesugaringEnabled = true
}
}
If not, what is the default value? Maybe it changed in the new version of the Android plugin.
I believe that this setting is not compatible with the android-retrofix plugin.
There was no coreLibraryDesugaringEnabled
entry in my build.gradle. I tried coreLibraryDesugaringEnabled false
but this didn't help either.
I tried to build with the old Gradle and Gradle Plugin and it works for Android 5 then.
classpath 'com.android.tools.build:gradle:4.1.3'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
A fix for the latest Android Studio 4.2.1 would be great.
I have exactly the same issue, as aloz77 does, on:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
java.lang.NoClassDefFoundError: com.hivemq.client.internal.mqtt.-$$Lambda$Df8yRNpuHjFWi4vVWQkOSvVrarE
at com.hivemq.client.internal.mqtt.MqttClientTransportConfigImplBuilder.webSocketConfig(MqttClientTransportConfigImplBuilder.java:206)
at com.hivemq.client.internal.mqtt.MqttRxClientBuilder.webSocketConfig(MqttRxClientBuilder.java:39)
The only workaround for me until now was downgrading AGP to 4.1.3. Maybe it has something to do with AGP 4.2.1 using Java 8 language level by default?
Disabling core lib desugaring doesn't help.
But enabling it, like this does help:
android {
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
...
}
and the NoClassDefFoundError
is gone on Android 6.
Is this now recommended solution when using HiveMQ client and AGP 4.2.1, even if I'm using only Kotlin in my project? Or RetroFix plugin needs a fix?
Hi @digrec
The problem with coreLibraryDesugaring
is, that Android still only supports a subset of the Java 8 libraries, for example a CompletableFuture backport is missing iirc.
Imho the android-retrofix plugin needs an update to support the new android plugin which seems to have broken backwards compatibility.
Same problem. Downgrade AGP 4.1.3 fixed for now.
Any progress on this maybe? It doesn't actually work in AGP 7 too. I opened a retrofix issue too before seeing this issue here.
Having the same problem, any other fixes apart from downgrading gradle ?
Any news on this? 🙏
@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.
Yes, looks like working now. Tested with Android 6.
@SgtSilvio thanks for the fix, the original issue is now resolved. Tested on Android 6 and 7.
But one of our android apps is now failing to build with: Cause: module-info class is frozen
I reported the issue here https://github.com/SgtSilvio/android-retrofix/issues/11
Any suggestions?
@digrec should be fixed in the new version 0.4.1 (https://github.com/SgtSilvio/android-retrofix/releases/tag/v0.4.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
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
dependencies:
buildscript/dependencies:
apply plugin: 'com.github.sgtsilvio.gradle.android-retrofix'