简体   繁体   English

尝试为应用构建APK时出错

[英]Error when trying to build APK for app

I get this error when I try to build my app in Android Studio 当我尝试在Android Studio中构建应用程序时收到此错误

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. 错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: retrofit2/BuiltInConverters$BufferingResponseBodyConverter.class com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:retrofit2 / BuiltInConverters $ BufferingResponseBodyConverter.class

Here are my dependencies: 这是我的依赖项:

compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-analytics:9.0.2'
compile 'com.google.firebase:firebase-config:9.0.2'
compile 'com.google.firebase:firebase-auth:9.0.2'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.2'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.android.support.constraint:constraint-layout:+'
compile 'com.android.support:multidex:1.0.1'

It seems like some jar files are not compiled properly. 似乎某些jar文件未正确编译。

Try to clean or Rebuild the project 尝试清理或重建项目

If it doesn't help than remove the jar file and try to add it again 如果这无助于删除jar文件,然后尝试再次添加它

I am sure it will help 我相信这会有所帮助

What you showed looks good. 您显示的内容看起来不错。

According to the error, you have duplicate converter class. 根据错误,您有重复的转换器类。

Remove any retrofit jars in you libs folder, then run gradle build again 删除libs文件夹中的所有翻新罐,然后再次运行gradle build

Remove the gson library u have added separately. 删除您单独添加的gson库。 Only the one with the retrofit is required. 只需要进行改造的那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM