Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Android 5 (API 21) #2

Closed
FedericoMatera opened this issue Aug 6, 2019 · 6 comments
Closed

Crash on Android 5 (API 21) #2

FedericoMatera opened this issue Aug 6, 2019 · 6 comments
Labels
question Further information is requested

Comments

@FedericoMatera
Copy link

I added apply plugin: 'com.github.sgtsilvio.gradle.android-retrofix' in my project but if I try to connect via MQTT on Android 5 the app crashes with this error:

Caused by: java.lang.NoClassDefFoundError: com.hivemq.client.internal.mqtt.message.connect.mqtt3.-$$Lambda$Wn55JBsOAP1F2GOaN0qiXRejLL0
        at com.hivemq.client.internal.mqtt.message.connect.mqtt3.Mqtt3ConnectViewBuilder.simpleAuth(Mqtt3ConnectViewBuilder.java:80)
@SgtSilvio
Copy link
Owner

You have to set:

android {
    ...
    compileOptions {
        // enables lambdas, method references, default methods, static interface methods
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    ...
}

@FedericoMatera
Copy link
Author

FedericoMatera commented Aug 6, 2019

I had.
I have this config:
root:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        gradlePluginPortal()
    }
    dependencies {
        ...
        classpath 'gradle.plugin.com.github.sgtsilvio.gradle:android-retrofix:0.2.1'
    }
}

app:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.github.sgtsilvio.gradle.android-retrofix'

android {
   ...
   compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    ...
    implementation project(":data")
    implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.1'
    implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.1'
}

data:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
   ...
   compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    ...
    implementation 'com.hivemq:hivemq-mqtt-client:1.1.1'
}

@SgtSilvio
Copy link
Owner

Did you add

dependencies {
    ...
    implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.1'
    implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.1'
}

to your app project?

@FedericoMatera
Copy link
Author

yes, I updated the comment ^

@SgtSilvio
Copy link
Owner

The error is caused because the classes of the hivemq-mqtt-client dependency are not backported at all.
I think this is caused because of the hivemq-mqtt-client dependency being a transitive dependency in your case.
Can you try adding implementation 'com.hivemq:hivemq-mqtt-client:1.1.1' to your app dependencies to verify this?

@FedericoMatera
Copy link
Author

Now it works! Thank you!

@SgtSilvio SgtSilvio added the question Further information is requested label Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants