java util zip ZipException:重复条目 [英] java util zip ZipException: duplicate entry

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

问题描述

在运行项目时出现此错误

While running the project I'm getting this error

错误:任务:........"的执行失败.com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:javax/annotation/CheckForNull.class

Error:Execution failed for task ':..........'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class

这就是我的 app:gradle 的样子:

This is how my app:gradle looks like :

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary  'org.apache.http.legacy'

defaultConfig {
    applicationId "com.sample.Example"
    minSdkVersion 15
    targetSdkVersion 24
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile (project(':library')){
    exclude module: 'support-v4'
}
compile (project(':facebookLib')){
    exclude module: 'support-v4'
}
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.4'
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/FlurryAgent.jar')
compile files('libs/google-api-client-1.15.0-rc.jar')
compile files('libs/google-api-client-android-1.15.0-rc.jar')
compile files('libs/google-api-services-androidpublisher-v1-rev15-1.15.0-rc.jar')
compile files('libs/google-http-client-1.15.0-rc.jar')
compile files('libs/google-http-client-android-1.15.0-rc.jar')
compile files('libs/google-http-client-jackson-1.15.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.15.0-rc.jar')
compile files('libs/google-oauth-client-1.15.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.15.0-rc.jar')
compile files('libs/httpmime-4.2.jar')
compile files('libs/in-app-purchasing-1.0.3.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jackson-core-asl-1.9.11.jar')
compile files('libs/json_simple-1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/picasso-2.1.1.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/amazon-device-messaging-1.0.1.jar')
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:multidex:1.0.1'
}

截击:gradle

android {
compileSdkVersion 17
buildToolsVersion "24.0.3"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 8
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

库:gradle

android {
compileSdkVersion 16
buildToolsVersion "23.0.3"

defaultConfig {
    minSdkVersion 4
    targetSdkVersion 4
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:18.0.0'
}

facebookLib:gradle

facebookLib:gradle

android {
compileSdkVersion 17
buildToolsVersion "24.0.3"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 8
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:support-v4:18.0.0'
}

有人可以提出解决此错误的方法吗?提前致谢.

Can someone suggest a way out of this error ? Thanks in advance.

推荐答案

com.android.support:support-v4:_____

这个库被多次使用.所以这就是你可以做的.在您图书馆的 gradle 或 facebooklib 的 gradle 上执行此操作:

This library is used multiple times. So here's what you can do. do this on either your library's gradle or facebooklib's gradle:

compile(project(':facebookLib')) {
    exclude module: 'support-v4'
}

compile(project(':library')) {
    exclude module: 'support-v4'
}

提示:您应该在构建时创建一个 gradle 任务来打印您的依赖项并查看它.看看有没有什么可以删除/改进的

Tip: You should make a gradle task to print your dependencies when building and take a look at it. See if there is anything you can remove/improve

在 Android Studio 的终端选项卡中运行此命令.

run this command in the terminal tab of your Android Studio.

./gradlew app:dependencies

这将打印出所有依赖项及其(子)依赖项.查看它并查看哪个依赖项在何处被调用两次.

This will print out all dependencies and their (sub)dependencies. Look through it and see which of the dependency is called twice where.

每次看到同一个库两次时,就必须使用上面显示的 exclude 方法来排除该模块或组.

Every time you see the same library twice, you have to use the exclude method showed above to exclude that moudle or group.

请参阅此处了解更多详情.这是很好和简单的解释.https://www.linkedin.com/pulse/how-find-dependencies-particular-dependency-gradle-hesamedin-kamalan-1

See here for more details. It's nice and simple explanation. https://www.linkedin.com/pulse/how-find-dependencies-particular-dependency-gradle-hesamedin-kamalan-1

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

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