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