在尝试构建APK时获取错误“重复条目:com / google / android / gms / internal / zzaac $ zza.class”

时间:2018-03-12 15:27:06

标签: android android-studio gradle android-gradle

您好我正在尝试构建APK但我在Android Studio中遇到此问题。

  

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

这是我的gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "someId"
        minSdkVersion 19
        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'
        }
    }



}

dependencies {

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

    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.firebase:firebase-messaging:10.2.4'
    compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
}

这是我的gradle(项目)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

3 个答案:

答案 0 :(得分:1)

由于gcm播放服务存在冲突,因此不同的版本会导致重复的内容

从build.gradle中删除它

 compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'

添加此

 compile 'com.firebase:firebase-jobdispatcher:0.8.5'

答案 1 :(得分:0)

尝试在build.gradle(app)文件的底部添加此行。

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

classpath 'com.google.gms:google-services:3.1.1'
build.gradle(project)中的

答案 2 :(得分:0)

在尝试了几个小时后它正在为我工​​作,这将使缓存无效并在android studio的下一次启动时重建项目

  

档案>无效的缓存/重启。