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
556 views
in Technique[技术] by (71.8m points)

android - zip.ZipException: duplicate entry: annotations/Beta.class

I have been struggling for more that a day to fix the duplicate entry given when running my android project.

Error:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.> java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class

I've tried to exclude various modules as well as enable multiDex, and have hit a wall, please help me solve this problem:

part of code:

 compile(project(path: ':k_endpoint', configuration: 'android-endpoints')) {
    exclude(group: 'com.google.guava', module: 'guava-jdk5')
    exclude(group: 'com.android.support', module: 'support-annotations')
}

compile ('com.android.support:multidex:1.0.1')
compile ('com.android.support:appcompat-v7:22.2.0')
compile ('com.google.android.gms:play-services:8.1.0')
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile ('com.android.support:cardview-v7:22.2.0')
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'

I have tried the exclude 'support annotations' at the recyclerview and cardview, because both seem to have the module, but doesn't help in any way.

The endpoint code:

dependencies {
compile 'com.google.guava:guava-jdk5:17.0'
appengineSdk ('com.google.appengine:appengine-java-sdk:1.9.19'){
}

compile ('com.google.appengine:appengine-endpoints:1.9.19')
compile ('com.google.appengine:appengine-endpoints-deps:1.9.19')
compile ('javax.servlet:servlet-api:2.5')
compile ('com.googlecode.objectify:objectify:5.1.1')
compile ('com.ganyo:gcm-server:1.0.2')
compile ('com.sendgrid:sendgrid-java:2.2.1'){
    exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    exclude(group: 'org.json', module: 'json')
}

I tried to find the conflicts with below, not sure if annotations is the correct module to search for in the first place.

./gradlew -q :app:dependencyInsight --dependency annotations --configuration compile

Results:

+--- com.android.support:recyclerview-v7:22.2.0
 |    --- compile
--- com.android.support:support-v4:22.2.0
 +--- com.android.support:appcompat-v7:22.2.0
 |    +--- compile
 |    +--- com.android.support:design:22.2.0
 |    |    --- compile
 |    --- com.android.support:mediarouter-v7:22.2.0
 |         --- com.google.android.gms:play-services-cast:8.1.0
 |              --- com.google.android.gms:play-services:8.1.0
 |                   --- compile
 +--- com.android.support:design:22.2.0 (*)
 +--- com.android.support:recyclerview-v7:22.2.0 (*)
 --- com.google.android.gms:play-services-basement:8.1.0
      +--- com.google.android.gms:play-services:8.1.0 (*)
      +--- com.google.android.gms:play-services-ads:8.1.0
 etc
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

In order to systematically resolve "ZipException: duplicate entry" errors check out my answer here. If you do not use multidex, just ignore the multidex part. I encountered the exact same error regarding Beta.class and resolved it by excluding all occurences of guava:

compile ('com.google.dagger:dagger:2.4') { exclude group: 'com.google.guava' }


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

1.4m articles

1.4m replys

5 comments

57.0k users

...