com.android.build.api.transform.TransformException:java.util.zip.ZipException:duplicate entry:com / google / android / gms / common / api / zza.class [英] com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class

查看:2049
本文介绍了com.android.build.api.transform.TransformException:java.util.zip.ZipException:duplicate entry:com / google / android / gms / common / api / zza.class的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是在应用程序模块中添加Firebase,google服务和google-services.json后获得的错误。



我有13个模块应用程序。我在所有模块中有7个构建变体。我尝试将google-services.json放在app模块中,并将其放在app模块中的build variant文件夹中。我得到相同的错误。我有一个构建变体的通知功能。



我从应用程序中删除了gradle和google-services.json中的firebase相关代码,工作正常。 >

由于安全原因,我无法共享整个文件。



主应用程序模块gradle:

 依赖关系{
编译fileTree(include:['* .jar'],dir:'libs')
testCompile' junit:junit:4.12'
debugCompile'c​​om.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile'c​​om.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
testCompile'c​​om.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar'){
transitive = true;
}
编译'com.android.support:appcompat-v7:23.4.0'
compile'c​​om.android.support:design:23.4.0'
compile'c​​om $。$。 b compile'c​​om.github.hotchemi:permissionsdispatcher:2.0.7'
apt'com.github.hotchemi:permissionsdispatcher-processor:2.0.7'
compile'org.greenrobot:eventbus:3.0.0 '
compile'c​​om.android.support:multidex:1.0.1'

}

在应用程序毕业:

 依赖项{
classpath'com.android.tools.build :gradle:2.1.3'

//注意:请勿在此处放置应用程序依赖项;他们属于
//在个别模块build.gradle文件
classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'

classpath'com.google。 gms:google-services:3.0.0'
}




:app:transformClassesWithJarMergingForSmePreDebug FAILED
FAILURE:Build failed with a exception。

  *出了什么问题:
任务执行失败:app:transformClassesWithJarMergingForSmePreDebug'。>

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


这个问题在StackOverflow中有很多链接。没有固定我的问题。任何建议赞赏。



已编辑推送通知模块gradle:

 $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com com .android.support:appcompat-v7:23.4.0'
//编译'com.google.android.gms:play-services-gcm:9.0.0'

compile'c​​om .google.firebase:firebase-messaging:9.8.0'
// compile('com.google.firebase:firebase-messaging:9.8.0'){
// exclude group:'com。 google.android.gms'
//}
}
应用插件:'com.google.gms.google-services'


解决方案

此问题可能是因为您有重复的依赖关系。一个有最新版本,另一个有旧版本。



您可以做的是


  1. 检查您的应用依赖项。

      ./ gradlew clean:app:dependencies 


  2. 查找包含com.google.android.gms的第三方库。


  3. 排除此

      compile('library'){
    exclude group:'com.google.android.gms '
    }


这可能是能够快速解决。但是这不是很好!



最好的解决方案应该是更新你的第三方库,他们的最新版本可能已经更新了他们的谷歌服务库。


Below is the error I am getting after adding the Firebase, google services in gradle and google-services.json in app module.

I have 13 modules in my app. I have 7 build variants in all the modules. I tried with placing the google-services.json in app module and placing it in build variant folder inside the app module. I am getting same error. I have the notification feature in one build variant.

I removed the firebase related code in gradle and google-services.json from application, it is working perfectly.

Due to security reason I can't share the entire file.

Main app module gradle:

dependencies {
   compile fileTree(include: ['*.jar'], dir: 'libs')
   testCompile 'junit:junit:4.12'
   debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
   releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
   testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
   compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
       transitive = true;
   }
   compile 'com.android.support:appcompat-v7:23.4.0'
   compile 'com.android.support:design:23.4.0'
   compile 'com.android.support:support-v4:23.4.0'
   compile 'com.jakewharton:butterknife:8.2.1'
   apt 'com.jakewharton:butterknife-compiler:8.2.1'
   compile 'com.github.hotchemi:permissionsdispatcher:2.0.7'
   apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.7'
   compile 'org.greenrobot:eventbus:3.0.0'
   compile 'com.android.support:multidex:1.0.1'

}

In Application gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

    classpath 'com.google.gms:google-services:3.0.0'
}

:app:transformClassesWithJarMergingForSmePreDebug FAILED FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForSmePreDebug'.>

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class

I reffered many links in StackOverflow for this issue. None fixed my problem. Any suggestions appreciated.

Edited push notification module gradle:

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.4.0'
   //compile 'com.google.android.gms:play-services-gcm:9.0.0'

   compile 'com.google.firebase:firebase-messaging:9.8.0'
   //compile ('com.google.firebase:firebase-messaging:9.8.0') {
      //exclude group: 'com.google.android.gms'
   //}
}
apply plugin: 'com.google.gms.google-services'

解决方案

This issue might because you have duplicate dependencies. One has latest version and the other one has old version.

What you can do is

  1. check your app dependecies.

    ./gradlew clean :app:dependencies
    

  2. find 3rd party libraries that also have com.google.android.gms included.

  3. exclude this group from the library

    compile ('library') {
        exclude group: 'com.google.android.gms' 
    }
    

This might be able to be a quick fix. But it's not good!

The best solution should be updating your 3rd party library, their latest version might update their google services library already.

这篇关于com.android.build.api.transform.TransformException:java.util.zip.ZipException:duplicate entry:com / google / android / gms / common / api / zza.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆