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

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

问题描述

在运行项目时,我收到此错误

While running the project I'm getting this error


错误:执行失败的任务':....... ......。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:duplicate entry: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

这是我的应用程序: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'
}

凌空:毕业

android {
compileSdkVersion 17
buildToolsVersion "24.0.3"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 8
}

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

库:毕业

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:_____

此库被多次使用。所以这是你可以做的。在你的图书馆的毕业生或者facebooklib的毕业生上这样做:

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

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

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-specific-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天全站免登陆