当我尝试运行应用程序时,构建失败

pro*_*ion 1 android google-cloud-messaging

我有错误,如"错误:任务执行失败":app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/internal/zzpm $ zza $ zza.class"

我该怎么做才能消除这个错误

gradle这个

apply plugin: 'com.android.application'


 android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"



defaultConfig {
    applicationId "com.example.user.merchant"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

  dependencies {
   compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
   compile 'com.android.support:design:23.2.0'
   compile 'com.android.support:support-v4:23.2.0'
   compile 'com.android.volley:volley:1.0.0'
   compile 'com.google.android.gms:play-services-appindexing:8.4.0'
   compile 'com.google.android.gms:play-services-gcm:8.4.0'
    //compile files('libs/google-play-services.jar')

   }
Run Code Online (Sandbox Code Playgroud)

Ale*_*ran 5

正如@Vaiden所说,问题是:

"您似乎至少有一个图书馆已与GMS捆绑在一起"

每次遇到重复输入错误时 都要运行./gradlew app:dependencies 并确保没有相同模块的重复版本.例如:在我的情况下,我有:

compile 'com.google.android.gms:play-services-gcm:9.0.0'
Run Code Online (Sandbox Code Playgroud)

当我尝试在我的项目中使用firebase时,我添加它:

compile 'com.google.firebase:firebase-core:9.+'
compile 'com.google.firebase:firebase-messaging:9.+'
Run Code Online (Sandbox Code Playgroud)

这使我的应用程序崩溃导致当我导航到:app > build > intermediates > exploded-aar > com.google.android.gms其中一个文件夹(play-services-basement)拉出版本9.4.0而不是9.0.0所以我做的是通过添加firebase来解除版本:

compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
Run Code Online (Sandbox Code Playgroud)

理论上你也可以通过推动火柱来解决这个问题9.4.0.

最重要的是试图知道哪些东西是你的应用程序引入应用程序,并检查"WHO"是否向应用程序引入相同的东西,一旦你到达那里尝试设置该重复依赖项的特定版本.