如何修复Android Studio中的重复依赖项?

如何修复Android Studio中的重复依赖项?,android,firebase,android-studio,Android,Firebase,Android Studio,我正在尝试编译和构建我的项目,但每当我构建我的项目时,我都会出现重复错误,当我将firebase依赖项添加到我的项目时,我通过在线研究解决了第一个问题,我添加了这个实现implementation'com.google.guava:guava:27.0.1-android',以修复冲突,现在我添加了一个新的firebase依赖项,它是implementation'com.google.firebase:firebase config:16.1.0'我仍然无法构建我的应用程序 在模块jetifie

我正在尝试编译和构建我的项目,但每当我构建我的项目时,我都会出现重复错误,当我将firebase依赖项添加到我的项目时,我通过在线研究解决了第一个问题,我添加了这个实现
implementation'com.google.guava:guava:27.0.1-android'
,以修复冲突,现在我添加了一个新的firebase依赖项,它是
implementation'com.google.firebase:firebase config:16.1.0'
我仍然无法构建我的应用程序

在模块jetified-firebase-analytics-impl-16.2.2-runtime(com.google.firebase:firebase-analytics impl:16.2.2)和jetified-play-services-measurement-18.0.2-runtime(com.google.android.gms:play-services-measurement:18.0.2)中找到重复的类com.google.android.measurement.internal.zzu D

下面是我的build.gradle代码

apply plugin: 'com.android.application'

android {

    compileSdkVersion 30
    buildToolsVersion '29.0.3'

    defaultConfig {
        applicationId "com.sckoolboy.app"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 20210420
        versionName '5.1.1'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

    dexOptions {
        javaMaxHeapSize = "4g"
        jumboMode true
    }

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

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    productFlavors {
    }
}

dependencies {
    implementation  fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.github.vivchar:ViewPagerIndicator:1.1.0'
    implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.4.1'
    implementation 'com.google.firebase:firebase-config:16.1.0'

    implementation 'com.anjlab.android.iab.v3:library:1.1.0'
    implementation 'com.facebook.android:facebook-login:6.3.0'
    implementation 'com.facebook.android:audience-network-sdk:5.11.0'
    implementation 'com.google.android.ads.consent:consent-library:1.0.8'
    implementation 'devlight.io:navigationtabbar:1.2.5'
    implementation 'com.miguelcatalan:materialsearchview:1.4.0'
    implementation 'com.github.bhargavms:DotLoader:1.1.1'
    implementation 'com.leinardi.android:speed-dial:2.0.1'
    implementation 'com.orhanobut:hawk:2.0.1'
    implementation 'com.github.codemybrainsout:smart-app-rate:1.0.8'
    implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.10.8'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.8'
    implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
    implementation "com.google.android.gms:play-services-location:17.0.0"
    implementation 'com.github.joielechong:countrycodepicker:2.4.2'
    implementation 'com.squareup.okhttp3:okhttp:4.4.1'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
    implementation 'com.github.GrenderG:Toasty:1.4.2'

    implementation 'com.google.android.play:core:1.10.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.chrisbanes.photoview:library:1.2.3'
    implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.mediarouter:mediarouter:1.2.1'
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.gms:play-services-auth:18.1.0'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-ads:19.3.0'
    implementation 'com.google.firebase:firebase-core:18.0.2'
    implementation 'com.google.firebase:firebase-ads:19.7.0'
    implementation 'com.google.firebase:firebase-messaging:21.1.0'
    implementation 'com.google.firebase:firebase-analytics:18.0.2'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.google.firebase:firebase-firestore:21.4.2'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.7.0'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.android.billingclient:billing:3.0.2'
    implementation 'com.google.android.exoplayer:exoplayer:2.7.2'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.android.material:material:1.3.0-alpha03'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.google.guava:guava:27.0.1-android'


    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'jp.wasabeef:richeditor-android:1.2.2'
    implementation 'com.github.QuadFlask:colorpicker:0.0.13'
    implementation  files('libs/YouTubeAndroidPlayerApi.jar')
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}

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

请问我做错了什么?100万感谢您在这方面的帮助。

请检查您的
依赖关系

dependencies {
    // ...
    implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.10.8'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.8'

    // ...
    implementation 'com.google.android.exoplayer:exoplayer:2.7.2'

    // ...
}
删除副本

implementation 'com.google.android.exoplayer:exoplayer:2.7.2'

帮助

您已使用不同版本添加了两次Exoplayer依赖项

implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer:2.7.2'

检查你的Gradle文件并删除重复的文件。

当你在代码中添加可以优化或不需要的内容时,Android Studio具有突出显示该内容的功能。在这种情况下,如果你添加了未使用的、重复的或不需要的依赖项,Android Studio将在下方突出显示它们

将鼠标悬停在突出显示的黄色线条上,Android Studio可能会显示一些建议,如下所示


如上图所示,通过删除重复的依赖项,您可以删除重复的依赖项,这也将优化您的项目

我没注意到这个复制品,很快。呸!!!非常感谢要接受这个答案,如果你找到了一个解决方案来鼓励人们在堆栈溢出帮助更多的用户,像youHi Osas Divine,我已经为你的问题添加了一个答案。如果这是你正在寻找的东西,请将其标记为正确答案,以便其他人可以参考。如果它在你的情况下不起作用,你可以在下面的答案中发表评论!