Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

android - Gradle Duplicate Entry: java.util.zip.ZipException

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 

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 (*)

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'
        }

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...