如何修复Android项目构建上的重复类

时间:2019-06-21 22:30:11

标签: android gradle

那是我的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.it.munchies"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
        multiDexEnabled true

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.google.code.gson:gson:2.3.1'

    implementation 'com.facebook.android:facebook-android-sdk:4.8.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.firebase:firebase-auth:9.6.1'
    implementation 'com.google.android.gms:play-services-auth:10.0.1'
    implementation 'com.google.firebase:firebase-core:9.6.1'
    implementation 'com.google.android.gms:play-services-maps:10.0.1'
    implementation 'com.google.android.gms:play-services-places:10.0.1'
    implementation 'com.google.firebase:firebase-messaging:10.2.1'
    implementation 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation files('libs/httpmime-4.2.1.jar')
    implementation 'me.leolin:ShortcutBadger:1.1.9@aar'
// routing
    implementation 'com.github.jd-alexander:library:1.0.7'
    implementation('io.socket:socket.io-client:0.8.3') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    implementation 'com.android.support:support-annotations:28.0.0'
}

// For FCM
apply plugin: 'com.google.gms.google-services'

错误日志:

Duplicate class com.google.android.gms.internal.zzaac found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzaac$zza found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzaba found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzabd found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzabe found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzabf found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzabg found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzabu found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzaca found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzaca$zza found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzacm found in modules classes.jar (com.google.android.gms:play-services-base:10.0.1) and classes.jar (com.google.android.gms:play-services-basement:10.2.1)
Duplicate class com.google.android.gms.internal.zzvk found in modules classes.jar (com.google.android.gms:play-services-auth-base:10.0.1) and classes.jar (com.google.firebase:firebase-analytics-impl:9.6.1)
Duplicate class com.google.android.gms.internal.zzvk$zza found in modules classes.jar (com.google.android.gms:play-services-auth-base:10.0.1) and classes.jar (com.google.firebase:firebase-analytics-impl:9.6.1)



Duplicate class com.google.android.gms.internal.zzvl found in modules classes.jar (com.google.android.gms:play-services-auth-base:10.0.1) and classes.jar (com.google.firebase:firebase-analytics-impl:9.6.1)
Duplicate class com.google.android.gms.internal.zzvl$zza found in modules classes.jar (com.google.android.gms:play-services-auth-base:10.0.1) and classes.jar (com.google.firebase:firebase-analytics-impl:9.6.1)
Duplicate class com.google.android.gms.internal.zzvm found in modules classes.jar (com.google.android.gms:play-services-auth-base:10.0.1) and classes.jar (com.google.firebase:firebase-analytics-impl:9.6.1)

2 个答案:

答案 0 :(得分:1)

尝试将所有Firebase依赖项设置为相同的版本10.0.1。

implementation 'com.google.firebase:firebase-auth:10.0.1'
implementation 'com.google.android.gms:play-services-auth:10.0.1'
implementation 'com.google.firebase:firebase-core:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
implementation 'com.google.android.gms:play-services-places:10.0.1'
implementation 'com.google.firebase:firebase-messaging:10.0.1'

答案 1 :(得分:1)

您要导入的那些依赖项的版本都已经过时了。查看最新版本和发行说明here

如果可能的话,我强烈建议您更新到这些依赖项的最新版本,以期解决您在此处显示的错误。