为什么我的项目 运行 时会出现此 google 番石榴错误?

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

每当我尝试 运行 我的项目时,我都会收到以下错误:

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)

完整堆栈跟踪:https://pastebin.com/8UBsXxme

gradle 个文件:

基于应用:

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'


}

基于项目:

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
}

我尝试了 rebuilding/cleaning 项目并与 gradle 文件同步,但 none 成功了。

问题似乎是 com.google.guava:guava-annotations:r03 的原因,但我不知道如何找到使用此注释的依赖项。我能做什么?

表示GoogleGuava的注解@Beta在你的构建中出现了两次

只需摆脱 com.google.guava:guava-annotations:r03 神器。它是从 2010 年开始的,没有更新,也不再受支持。该包中的所有注释都包含在最新的 Guava 版本中。

步骤:

  1. 找出需要哪个包com.google.guava:guava-annotations:r03

    ./gradlew app:dependencies
    
  2. 移除依赖:

    compile('com.example.m:m:1.0') {
      exclude group: 'com.google.guava', module: 'guava-annotations'
    }