在模块中发现重复 class com.google.android.gms.location.places.zza

Duplicate class com.google.android.gms.location.places.zza found in modules

我正在尝试将 Place Autocomplete 小部件实现到 Android 应用程序,但是当我添加依赖项时,我开始收到与依赖项冲突的错误,我尝试了所有已回答的问题,但没有一个对我有用:

Duplicate class com.google.android.gms.location.places.zza found in modules jetified-play-services-places-11.8.0-runtime.jar (com.google.android.gms:play-services-places:11.8.0) and jetified-play-services-places-placereport-17.0.0-runtime.jar (com.google.android.gms:play-services-places-placereport:

刚刚添加了以下依赖项,并开始出现问题。

implementation 'com.google.android.libraries.places:places:2.3.0'

下面是我的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
        config {
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 29
    defaultConfig {
        applicationId ""
        minSdkVersion 23
        targetSdkVersion 29

        versionCode 90
        versionName "4.2.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }

    buildToolsVersion '27.0.3'
    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
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
    implementation 'com.mobsandgeeks:android-saripaar:2.0.3'
    implementation 'androidx.cardview:cardview'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.daimajia.easing:library:2.0@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'
    implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
    implementation 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'
    implementation 'com.myhexaville:smart-image-picker:1.0'
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
    compile 'com.github.delight-im:Android-SimpleLocation:v1.1.0'

    implementation 'com.afollestad:viewpagerdots:1.0.0'

    api('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
    //firebase dependencies
    implementation "com.google.firebase:firebase-core:$rootProject.firebaseVersion"
    implementation "com.google.android.gms:play-services-auth:$rootProject.firebaseVersion"
    implementation "com.google.firebase:firebase-auth:$rootProject.firebaseVersion"
    implementation "com.google.android.gms:play-services-maps:$rootProject.firebaseVersion"
    implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseVersion"
    implementation "com.google.android.gms:play-services:$rootProject.firebaseVersion"
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'jp.wasabeef:glide-transformations:3.1.0'
    implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
    implementation 'com.google.code.gson:gson:2.8.2'
    annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleCompilerVersion"
    implementation "android.arch.lifecycle:runtime:$rootProject.archLifecycleVersion"
    implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleExtensionsVersion"
    implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
    annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
    implementation 'com.miguelcatalan:materialsearchview:1.4.0'
    implementation 'org.greenrobot:eventbus:3.2.0'
    implementation 'com.google.android.libraries.places:places:2.3.0'

    //facebook dependencies
    implementation('com.facebook.android:facebook-android-sdk:5.13.0') {
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'cardview-v7'
        exclude group: 'com.android.support', module: 'customtabs'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-core-utils'
    }

    //for tuturial
    implementation 'com.github.florent37:tutoshowcase:1.0.1'
    implementation "androidx.fragment:fragment:1.1.0"
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    // Date Picker
    implementation 'com.wdullaer:materialdatetimepicker:3.0.0'

}
apply plugin: 'com.google.gms.google-services'
firebaseVersion = '11.8.0'
implementation "com.google.android.gms:play-services-auth:$rootProject.firebaseVersion"
implementation "com.google.android.gms:play-services-maps:$rootProject.firebaseVersion"
implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseVersion"
implementation "com.google.android.gms:play-services:$rootProject.firebaseVersion"

使用以下版本

com.google.android.gms:play-services-auth:18.0.0
com.google.android.gms:play-services-maps:17.0.0
com.google.firebase:firebase-messaging:20.2.1

如果不使用,您可以删除 implementation "com.google.android.gms:play-services:$rootProject.firebaseVersion"

可以升级

  buildToolsVersion '29.0.2'