3

Go to the documentation to learn how to Fix dependency resolution errors.

Duplicate class found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0)

I initially made this project, that used Google's Cloud Vision API and everything worked fine. But now I am unable to resolve this dependency which is required to integrate Firestore.

implementation 'com.google.firebase:firebase-firestore:21.4.3'

I have tried

implementation 'com.google.firebase:firebase-firestore:21.4.3' exclude module: 'com.google.gauva:gauva-jdk5:17.0'

and

configurations {
    implementation.exclude module:'gauva-jdk5'
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

and

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation 'com.google.guava:guava:26.0-android'

and

android.useAndroidX=true//causes lot of errors, tried refactoring, but core error remained
android.enableJetifier=true//no effect

as suggested in most other posts on StackOverflow, GitHub, etc. I also tried to clean and build multiple times. But nothing seems to be working so far. Including the Firestore implementation is the verified cause. The app build.gradle is

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
    applicationId "com.google.sample.cloudvision"
    minSdkVersion 24
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    buildTypes.each {
        it.buildConfigField 'String', 'API_KEY', "\"AIzaSyCuSEBxcK9n6_ojdCo6uUDFALdZL2w024Y\""
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
configurations {
    implementation.exclude module:'gauva-jdk5'
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
}

dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-firestore:21.4.3' exclude module: 'com.google.gauva:gauva-jdk5:17.0'
testImplementation 'junit:junit:4.12'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.2'
//noinspection GradleCompatible
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0' exclude module: 'com.google.gauva:gauva-jdk5:17.0'
//    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
//    implementation 'com.google.guava:guava:26.0-android'
}

The project build.gradle is

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.6.3'
    classpath 'com.google.gms:google-services:4.3.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    mavenCentral()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

The initial error log is as follows

Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.0.0-runtime.jar (androidx.core:core:1.0.0) and support-compat-27.0.2-runtime.jar (com.android.support:support-compat:27.0.2) Duplicate class com.google.common.annotations.Beta found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.annotations.GwtCompatible found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.annotations.GwtIncompatible found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.annotations.VisibleForTesting found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.base.Absent found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.base.AbstractIterator found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) Duplicate class com.google.common.base.AbstractIterator$1 found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-jdk5-17.0.jar (com.google.guava:guava-jdk5:17.0) ...............same error repeats for around 2300000 words........................................

gradle properties -> 5.6.4

AdityaLata
  • 31
  • 5

1 Answers1

7

may be it's too late. However, I am writing an answer to your problem.

I had the same issue. I was using the Youtube Data API v3. After few searches and seeing answers from Stackoverflow, I mixed all of them and somehow it worked!!

Here is all I did and it worked.

  1. Added configurations to app level build.gradle file. Like below

    configurations {
        implementation.exclude module:'guava-jdk5'
        all*.exclude group: 'com.google.guava', module: 'listenablefuture'
    }
    
  2. Added these two lines in dependency block

    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation 'com.google.guava:guava:31.1-android'
    
  3. And inside the dependencies needed for youtube data api I had

    exclude group:'com.google.guava'
    

Just like below

implementation ('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
    exclude group:'com.google.guava'
}
implementation ('com.google.apis:google-api-services-youtube:v3-rev183-1.22.0') {
    exclude group: 'org.apache.httpcomponents'
    exclude group:'com.google.guava'
}

If you want, you can have a look at my whole build.gradle file here at GitHub gist.

Thank you :-)

James
  • 4,573
  • 29
  • 32
Alison J.
  • 71
  • 2