程序重复的zip条目 [英] Prograurd Duplicate zip entry
问题描述
我在签署和发布APK时遇到问题。我得到Duplicate压缩文件警告和一个错误,下面是代码:
信息:Gradle tasks [:app:assembleRelease]
警告:无法写入资源[META-INF / MANIFEST.MF](复制zip条目[gcm.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META -INF / MANIFEST.MF](复制zip条目[gson-2.2.4.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](重复压缩条目[httpmime-4.2.2.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](重复的zip条目[joda-time- 2.1.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / LICENSE.txt](重复的zip条目[joda-time-2.1.jar:META-INF / LICENSE.txt])
警告:无法写入资源[META-INF / NOTICE.txt](复制zip条目[joda-time-2.1.jar:META-INF / NOTICE.txt])
警告:无法写入资源[META-INF / MANIFEST.MF](复制zip条目[splunk-mint-4.2.1.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](复制zip条目[universal-image-loader-1.9.4.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](复制zip条目[classes.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](复制zip条目[support-annotations-24.0.0.jar:META-INF / MANIFEST.MF])
警告:无法写入资源[META-INF / MANIFEST.MF](重复的zip条目[classes.jar :META-INF / MANIFEST.MF])
错误:任务':app:transformClassesWithMultidexlistForRelease'的执行失败。
> java.io.IOException:不能写[D:\Android\Android_Project\myapp\app\build\intermediates\multi-dex\release\componentClasses.jar](无法读取[C:\ Users \Amir Mahmoud \.android\build-cache\3936c6cf75e73634f829890fcc2030092ab8dabe\output\jars\classes.jar](重复的zip条目[classes.jar:android / support / v4 / view /ViewCompat$ICSViewCompatImpl.class]))
我甚至尝试在gradle中添加包装选项,但它确实不工作这是我的gradle代码:
apply plugin:'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion25.0.2
useLibrary'org.apache.http.legacy'
defaultConfig {
applicationIdcom.company.myapp
minSdkVersion 14
targetSdkVersion 21
versionCode 70
versionName7.4
testInstrumentati onRunnerandroid.support.test.runner.AndroidJUnitRunner
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard '
'
}
packagingOptions {
排除'META-INF / MANIFEST.MF'
排除' META-INF / NOTICE.txt'
}
lintOptions {
checkReleaseBuilds false
//或者,如果您愿意,您可以继续检查发布版本中的错误,
//但是即使发现错误也继续构建:
abortOnError false
}
}
依赖关系{
编译fileTree(包括:[ '* .jar'],dir:'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
exclude group:'com。 android.support',模块:'support-annotations'
})
// compile'com.android.support:appcompat-v4:25'
testCompile'junit:junit:4.12'
// compile fileTree(include:'* .jar' ,dir:'libs')
compile'com.google.android.gms:play-services:10.2.1'
// compilecom.google.android.gms:play-services-gcm :10.2.1
//编译'org.apache.httpcomponents:httpmime:4.5.3'
//编译文件('libs / gson-2.2.4.jar')
//编译文件('libs / httpmime-4.2.2.jar')
//编译文件('libs / joda-time-2.1.jar')
//编译文件('libs / universal-image-loader-1.9.4.jar')
//编译文件('libs / android-support-v4.jar')
}
我被困在这个项目上几天了,我不知道该怎么做,欢迎任何帮助。
除了Jared的回答,如果您收到有关重复 .class
文件,而不仅仅是 META-INF /
文件,您可能需要排除包含重复的违规模块。 class
file(s)。
您需要确定哪个依赖项包含具有重复 .class的模块条目并从该依赖项中排除该模块。
您可以使用Gradle命令: ./ gradlew app:dependencies
列出完整的依赖关系图。其中 app:
是项目模块/应用程序的名称。
使用 ./ gradlew app:dependencies
命令,您应该查看依赖关系列表,并找到包含具有重复 .class $ c $作为一个例子,可以说
是
//您的依赖项包括具有重复项的模块。
compile('com.my.project:my-module:0.1'){
//排除违规模块,所以不会有重复。
排除模块:'support-v4'
//也许你需要排除一个组吗?...
排除组:'com.google.android.gms'
}
I have a problem with signing and releasing an APK. I get Duplicate zip entry warnings and one error, Here is the code:
Information:Gradle tasks [:app:assembleRelease]
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [gcm.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [gson-2.2.4.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [httpmime-4.2.2.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [joda-time-2.1.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [joda-time-2.1.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [joda-time-2.1.jar:META-INF/NOTICE.txt])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [splunk-mint-4.2.1.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [universal-image-loader-1.9.4.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [support-annotations-24.0.0.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
Error:Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> java.io.IOException: Can't write [D:\Android\Android_Project\myapp\app\build\intermediates\multi-dex\release\componentClasses.jar] (Can't read [C:\Users\Amir Mahmoud\.android\build-cache\3936c6cf75e73634f829890fcc2030092ab8dabe\output\jars\classes.jar] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewCompat$ICSViewCompatImpl.class]))
I even tried adding packaging options to the gradle but it did not work this is my gradle code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.company.myapp"
minSdkVersion 14
targetSdkVersion 21
versionCode 70
versionName "7.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// compile 'com.android.support:appcompat-v4:25'
testCompile 'junit:junit:4.12'
// compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.google.android.gms:play-services:10.2.1'
// compile "com.google.android.gms:play-services-gcm:10.2.1"
// compile 'org.apache.httpcomponents:httpmime:4.5.3'
// compile files('libs/gson-2.2.4.jar')
// compile files('libs/httpmime-4.2.2.jar')
// compile files('libs/joda-time-2.1.jar')
// compile files('libs/universal-image-loader-1.9.4.jar')
// compile files('libs/android-support-v4.jar')
}
I am stuck on this project for a few days and I don't know what to do with it, any helps are welcomed.
In addition to Jared’s answer, if you receive an error about a duplicate .class
file(s), not just the META-INF/
files, you may need to exclude the offending module that includes the duplicate .class
file(s).
You will need to identify which dependency is including the module with the duplicate .class
entries and exclude that module from said dependency.
You can use the Gradle command: ./gradlew app:dependencies
to list the complete dependency graph. Where "app:
" is the name of your project's module/app.
After using the ./gradlew app:dependencies
command you should look through the list of dependencies and find the one that is including the offending module with the duplicate .class
entries.
As an example, lets say that com.android.support:support-v4
is the module with the duplicate classes that are causing these errors. Here's how to exclude that duplicate module from your dependency:
//Your dependency that includes the module with the duplicates.
compile('com.my.project:my-module:0.1') {
//exclude the offending module so there won’t be duplicates.
exclude module: 'support-v4'
//maybe you need to exclude a group also?...
exclude group: 'com.google.android.gms'
}
这篇关于程序重复的zip条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!