今天上傳文件的時候用了MultipartEntityBuilder,添加了httpcore等2個依賴庫,編譯運行的時候,studio出現一個奇怪的錯誤提示:
Duplicate files copied in APK META-INF/DEPENDENCIES File 1: /home/bluelife/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.5.jar File 2: /home/bluelife/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.5.jar
不知道哪里出錯,最后Google找到了解決方法。
需要在build.gradle文件里添加如下配置:
android { packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } // ... }
順利編譯。(注,我目前使用的版本是最新的candy版0.8.11)
