错误:任务执行失败:app:transformClassesWithJarMergingForDebug

时间:2017-04-18 06:28:13

标签: android android-gradle

  

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / android / gms / internal / zzbtk.class

当我运行我们的android studio项目时,会出现这些错误。我怎么能解决它们?

我的gradle文件:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.shikshamela.shikshamela"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'


    })


    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.android.support:support-v4:25.3.1'
    testCompile 'junit:junit:4.12'
}

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

4 个答案:

答案 0 :(得分:0)

apply plugin:'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.shikshamela.shikshamela"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'


    })




       compile 'com.android.support:multidex:1.0.1'
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support:design:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.google.android.gms:play-services-auth:10.2.1'
        compile 'com.google.firebase:firebase-messaging:10.2.1'
        compile 'com.google.firebase:firebase-core:10.0.1'
     compile 'com.google.firebase:firebase-auth:10.0.1'
     compile 'com.android.support:support-v4:25.3.1'              
     testCompile 'junit:junit:4.12'

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

答案 1 :(得分:0)

// copy paste below code

dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'


        })


        compile 'com.android.support:multidex:1.0.1'
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support:design:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.1'
        compile 'com.google.android.gms:play-services-auth:10.2.1'
        compile 'com.google.firebase:firebase-messaging:10.2.1'
        compile 'com.google.firebase:firebase-core:10.2.1'
        compile 'com.google.firebase:firebase-auth:10.2.1'
        compile 'com.android.support:support-v4:25.3.1'
        testCompile 'junit:junit:4.12'
    }

答案 2 :(得分:0)

尝试此更改

compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:25.3.1'
compile 'com.google.android.gms:play-services-auth:25.3.1'
compile 'com.google.firebase:firebase-messaging:25.3.1'
compile 'com.google.firebase:firebase-core:25.3.1'
compile 'com.google.firebase:firebase-auth:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'

 compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:25.3.1'
compile 'com.google.android.gms:play-services-auth:25.3.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'

答案 3 :(得分:0)

使相关的jars兼容,因此请更新这两个最新版本。

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'

更新到

compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'