打包 APK app-debug-unaligned.apk 期间出现重复文件 [英] Duplicate files during packaging of APK app-debug-unaligned.apk
问题描述
我收到这个错误 Duplicate files during Packaging of APK app-debug-unaligned.apk
当放置 2 个 jar 文件时:
I got this error Duplicate files during packaging of APK app-debug-unaligned.apk
when put 2 jar files :
httpclient-4.3.5.jar
httpmime-4.3.5.jar
在Sync with Gradle
和Run
之后进入libs
文件夹.
如果用户 1 jar 文件 - httpmime-4.3.5.jar
,我不会得到这个错误.
If user 1 jar file - httpmime-4.3.5.jar
, I will not get this error.
请帮助我如何避免这个错误&仍然可以使用上面的2个jar文件,
Please help me how to avoid this error & still can use 2 jar files in above also,
谢谢,
p/s :我使用 Android Studio 0.8.6 版.
p/s : I use Android Studio version 0.8.6.
错误详情
错误:APK 打包过程中文件重复...\app\build\outputs\apk\app-debug-unaligned.apk存档中的路径:META-INF/DEPENDENCIES来源 1: ...\app\libs\httpclient-4.3.5.jar来源 2: ...\app\libs\httpmime-4.3.5.jar
Error:duplicate files during packaging of APK ...\app\build\outputs\apk\app-debug-unaligned.apk Path in archive: META-INF/DEPENDENCIES Origin 1: ...\app\libs\httpclient-4.3.5.jar Origin 2: ...\app\libs\httpmime-4.3.5.jar
build.gradle
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.app'
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'de.hdodenhof:circleimageview:1.2.0'
compile files('libs/httpmime-4.3.5.jar')
}
UPDATE
我从 compile files('libs/httpmime-4.3.5.jar')
改为使用 Maven Link.将 2 个 maven 链接放在一起后,我再次遇到相同的错误:
UPDATE
I changed from compile files('libs/httpmime-4.3.5.jar')
to use Maven Link. I got same error again after put 2 maven link together:
compile 'org.apache.httpcomponents:httpmime:4.4-alpha1'
compile 'org.apache.httpcomponents:httpcore:4.4-alpha1'
这是警告
警告:依赖 org.apache.httpcomponents:httpclient:4.4-alpha1 是忽略调试,因为它可能与内部版本冲突安卓提供.有问题请用jarjar重新打包改类包
Warning:Dependency org.apache.httpcomponents:httpclient:4.4-alpha1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages
警告:依赖org.apache.httpcomponents:httpclient:4.4-alpha1 在发布时被忽略因为它可能与提供的内部版本冲突安卓.有问题请用jar重新打包换类包
Warning:Dependency org.apache.httpcomponents:httpclient:4.4-alpha1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jar to change the class packages
请帮我解决.
SOULITION 我知道现在通过添加这些行来解决Duplicate files
错误:
SOULITION I know good answer now by addding these lines will fix Duplicate files
error :
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
推荐答案
你可以用这个编译 'org 替换
.compile files('libs/httpmime-4.3.5.jar')
.apache.httpcomponents:httpmime:4.3.5'
You can replace compile files('libs/httpmime-4.3.5.jar')
with this compile 'org.apache.httpcomponents:httpmime:4.3.5'
.
你也在复制依赖 compile fileTree(include: ['*.jar'], dir: 'libs')
已经包含了 compile files('libs/httpmime-4.3.5.jar')
Also you are duplicating the dependencies compile fileTree(include: ['*.jar'], dir: 'libs')
already includes compile files('libs/httpmime-4.3.5.jar')
这篇关于打包 APK app-debug-unaligned.apk 期间出现重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!