今天調試 Android 應用遇到這麼個問題:
Duplicate files copied in APK META-INF/DEPENDENCIES File 1: httpmime-4.3.2.jar File 2: httpmime-4.3.2.jar
貌似說兩個包裡面的檔案重複了還是怎麼的,谷歌了一番之後據說應該是 android studio 自身的bug
解決辦法:
打開項目下面的 build.gradle 檔案,在 android 代碼塊中添加下面代碼
[sql]view plain copy print ?
- android {
- packagingOptions {
- exclude ’META-INF/DEPENDENCIES’
- exclude ’META-INF/NOTICE’
- exclude ’META-INF/LICENSE’
- exclude ’META-INF/LICENSE.txt’
- exclude ’META-INF/NOTICE.txt’
- }
- }
android {
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'
exclude 'META-INF/ASL2.0'
}
}
将這些檔案全部排出掉就ok了
但不知道這麼做會不會有什麼隐患,還是有其他更好的解決辦法
可以參考下這篇文章:http://stackoverflow.com/questions/20853094/gradle-and-android-studio-duplicate-file-copied-from-same-jar