简体   繁体   English

关于Retrofit和GSON的java.util.zip.ZipException

[英]java.util.zip.ZipException on Retrofit and GSON

Hi i am getting this error 嗨,我收到此错误

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. 错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。 com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / gson / annotations / Expose.class

When I added the retrofit GSON converter to my gradle here is my gradle. 当我将改装的GSON转换器添加到我的gradle中时,这是我的gradle。

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile files('libs/GenAsync.1.2.jar')
  compile files('libs/gson-2.2.4.jar')
  compile files('libs/KGJsonConverter.jar')
  compile files('libs/MD5Simply.jar')
  compile files('libs/PhotoUtil.jar')
  compile files('libs/android-viewbadger.jar')
  compile 'com.squareup.retrofit2:converter-gson:2.1.0'
  testCompile 'junit:junit:4.12'
  compile files('libs/retrofit-2.1.0.jar')
}

Can you help me guys with my problem? 你可以帮我解决我的问题吗? Thanks 谢谢

Class com.google.gson.annotations.Expose is defined in more than one dependency. com.google.gson.annotations.Expose类在多个依赖项中定义。 You need to exclude or remove conflicting dependencies. 您需要排除或删除冲突的依赖项。

Eg. 例如。 com.squareup.retrofit2:converter-gson:2.1.0 already contains transitive dependency com.google.code.gson:gson:2.7 so there is no need to declare also compile files('libs/gson-2.2.4.jar') . com.squareup.retrofit2:converter-gson:2.1.0已经包含传递依赖com.google.code.gson:gson:2.7所以没有必要声明也compile files('libs/gson-2.2.4.jar')

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

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