http://blog.youkuaiyun.com/nianhua120/article/details/50904905
HttpClient虽然已经被Google抛弃,但是有限项目依然依赖这些库,还得用。我把Httpclient的所有库导入项目后,会产生如下错误。
Error:duplicate files during packaging of APK F:\Downloads\MyApplication7\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES
Origin 1: F:\Downloads\MyApplication7\app\libs\httpclient-4.5.2.jar
Origin 2: F:\Downloads\MyApplication7\app\libs\httpcore-4.4.4.jar
经过查找可以在文件中加入以下代码消除这个问题。
- packagingOptions {
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- exclude 'META-INF/ASL2.0'
- exclude 'META-INF/notice.txt'
- }
HttpClient虽然已经被Google抛弃,但是有限项目依然依赖这些库,还得用。我把Httpclient的所有库导入项目后,会产生如下错误。
Error:duplicate files during packaging of APK F:\Downloads\MyApplication7\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES
Origin 1: F:\Downloads\MyApplication7\app\libs\httpclient-4.5.2.jar
Origin 2: F:\Downloads\MyApplication7\app\libs\httpcore-4.4.4.jar
经过查找可以在文件中加入以下代码消除这个问题。
- packagingOptions {
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- exclude 'META-INF/ASL2.0'
- exclude 'META-INF/notice.txt'
- }
本文介绍了解决在Android项目中使用HttpClient库时遇到的重复文件错误的方法。通过在项目配置文件中添加特定代码来排除冲突文件,从而避免打包APK时出现错误。
325

被折叠的 条评论
为什么被折叠?



