Gradle 重复条目:java.util.zip.ZipException [英] Gradle Duplicate Entry: java.util.zip.ZipException

查看:35
本文介绍了Gradle 重复条目:java.util.zip.ZipException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过其 Maven 存储库将 Zendesk 移动 sdk 集成到我的项目中,但它不再构建.它与我正在使用的毕加索图书馆存在某种冲突.我在构建过程中收到此错误:

I integrated the Zendesk mobile sdk through its maven repository into my project and it wouldn't build anymore. It has some kind of a clash with picasso library that i am using. I get this error during the build:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/squareup/picasso/Action$RequestWeakReference.class 

我在 app 文件夹上运行了 ../gradlew dependencies,这是我在 zendesk 模块下找到的:

I ran ../gradlew dependencies on the app folder and this is what i found under zendesk module:

\--- com.zendesk:sdk:1.0.0.1
     +--- com.squareup.retrofit:retrofit:1.4.1
     |    \--- com.google.code.gson:gson:2.2.4
     +--- com.squareup.picasso:picasso:2.3.2
     +--- com.android.support:support-v4:20.0.+ -> 21.0.3 (*)
     \--- com.android.support:appcompat-v7:20.0.+ -> 21.0.3 (*)

因此 zendesk 也在使用 picasso,但与我在项目中使用的版本不同.我尝试像这样从 zendesk 中排除毕加索:

So zendesk is also using picasso but a different version than what i have in my project. I tried excluding picasso from zendesk like this:

compile (group: 'com.zendesk', name: 'sdk', version: '1.0.0.1'){
            exclude group: 'com.squareup.picasso'
        }

但这会导致应用程序的其他组件中出现运行时异常.我收到一个与库完全无关的类的 NoDefFoundError.
有没有人知道如何解决这个问题?

but this causes runtime exceptions in other components of the app. I get a NoDefFoundError for a class totally unrelated to the libraries.
Does any one have any idea how to get around this problem ?

推荐答案

当您添加 com.android.support:multidex 依赖项时,您实际上添加了一些与其他依赖项冲突的依赖项.

我通过以下方式解决了:
---------------
1.搜索类,在你的情况下是RequestWeakReference.class"(在AndroidStudio中只需在Windows上按Ctrl + N或在Mac上按CMD-O)
2.查看哪个jar包含它 - Android Studio会在弹出窗口中写入它.
3. 从所有构建中排除它,例如:

When you added the com.android.support:multidex dependency you actually added some dependencies that collide with other dependencies.

I solved it by:
---------------
1. searching for the class, in you case the "RequestWeakReference.class" (in AndroidStudio just hit Ctrl+N on Windows or CMD-O on Mac)
2. See which jar contains it - Android Studio will write it in the popup.
3. Exclude it from all builds, for example:

android {
     configurations{
        all*.exclude module: 'servlet-api'
    }
}

这篇关于Gradle 重复条目:java.util.zip.ZipException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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