Why do i get this google guava error when running my project?

问题: Whenever I try to run my project i get following error: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:checkDebugDuplicateClasses'...

问题:

Whenever I try to run my project i get following error:

org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:checkDebugDuplicateClasses'.
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'
Caused by: com.android.ide.common.workers.WorkerExecutorException: 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.common.annotations.Beta found in modules guava-26.0-android.jar (com.google.guava:guava:26.0-android) and guava-annotations-r03.jar (com.google.guava:guava-annotations:r03)

full stacktrace: https://pastebin.com/8UBsXxme

gradle files:

app based:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.example.sanchez.worldgramproject"
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "0"


    }



    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }



    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }
}



dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    api "com.google.android.material:material:1.0.0"

    implementation 'com.github.madrapps:pikolo:1.1.6'
    implementation 'com.google.firebase:firebase-firestore:20.1.0'
    implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.jakewharton:butterknife:10.1.0'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.material:material:1.1.0-alpha07'
    implementation 'androidx.core:core:1.0.2'
    implementation 'com.firebaseui:firebase-ui-storage:2.3.0'
    implementation 'com.firebaseui:firebase-ui-database:4.3.1'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.0.0'
    implementation 'com.google.firebase:firebase-storage:18.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'uk.co.mgbramwell.geofire:geofire-android:0.0.2'
    implementation 'com.github.imperiumlabs:GeoFirestore-Android:v1.1.1'
    implementation 'com.yarolegovich:lovely-dialog:1.1.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation "com.google.android.gms:play-services-location:17.0.0"
    implementation 'com.github.yalantis:ucrop:2.2.3'
    implementation 'com.victor:lib:1.0.4'
    implementation 'androidx.emoji:emoji:1.0.0'
    implementation 'com.github.greenfrvr:hashtag-view:1.3.1'
    compile 'com.vanniktech:emoji-ios:0.6.0'



    testImplementation 'junit:junit:4.13-beta-3'


}

project based:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.3.0'

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

allprojects {
    repositories {
        jcenter()
        google()
        maven { url 'https://jitpack.io' }

    }
}



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

I tried rebuilding/cleaning the project and syncing with gradle files but none worked.

The problem seems to be the cause of com.google.guava:guava-annotations:r03, but i don't know how to find the dependencies which use this annotation. What can i do?


回答1:

It means that the annotation @Beta of Google Guava appears twice in your build.

Just get rid of the com.google.guava:guava-annotations:r03 artifact. It's from 2010, not updated, and not supported anymore. All the annotations from that package are included in recent Guava versions.

Steps:

  1. Find out which package requires com.google.guava:guava-annotations:r03

    ./gradlew app:dependencies
    
  2. Remove the dependency:

    compile('com.example.m:m:1.0') {
      exclude group: 'com.google.guava', module: 'guava-annotations'
    }
    
  • 发表于 2019-07-08 00:29
  • 阅读 ( 194 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除