auth0 / jwks-rsa-java

MIT License
196 stars 73 forks source link

Build error due to adding jwks-rsa-java library #46

Closed JohnAmadeo closed 6 years ago

JohnAmadeo commented 6 years ago

Hi!

I added jwks-rsa-java as a dependency in the build.gradle file in my /{PROJECT_NAME}/app directory as below (jwks-rsa-java is added right at the end)

apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.android.intouch_android"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "demo"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    def lifecycle_version = "1.1.1"

    // LiveData + ViewModel
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    // Retrofit (HTTP client library)
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    // GSON (JSON library)
    implementation 'com.google.code.gson:gson:2.8.5'

    // Parceler (library for de/serializing complex objects
    implementation 'org.parceler:parceler-api:1.1.11'
    annotationProcessor 'org.parceler:parceler:1.1.11'

    def nav_version = "1.0.0-alpha06"

    implementation "android.arch.navigation:navigation-fragment:$nav_version"
    implementation "android.arch.navigation:navigation-ui:$nav_version"

    def room_version = "1.1.1"

    implementation "android.arch.persistence.room:runtime:$room_version"
    annotationProcessor "android.arch.persistence.room:compiler:$room_version"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    // Identity authentication
    implementation 'com.auth0.android:auth0:1.14.1'
    implementation'com.auth0:java-jwt:3.4.1'
    implementation 'com.auth0:jwks-rsa:0.6.1'
}

When I try to build my project in Android Studio 3.3 Preview, I get an error saying:

Error: Program type already present: com.google.common.util.concurrent.internal.InternalFutureFailureAccess

I have confirmed that the build error is due to adding jwks-rsa-java. Would anyone happen to have a clue on what's going on here?

Thanks for the help!

lbalmaceda commented 6 years ago

java-jwt and jwks-rsa-java use apache commons lib as a dependency, thus they are not guaranteed to work on the android context. There's an alternative for decoding jwt but you mention that is not your problem now.

Can you confirm if this also happens using the previous version com.auth0:jwks-rsa:0.5.0?

JohnAmadeo commented 6 years ago

Thanks for the quick response - I really appreciate it!

So I tried using an older version and com.auth0:jwks-rsa:0.6.0 and it builds successfully on Android Studio!

However, I ended up using JWTDecode.Android, which seems to be the library I should have been using all along, and it worked perfectly for my use case.