端午小長假最後一天,大雨。隻好在家裡鼓搗自己喜歡的代碼了。
在将dom4j.jar也加入fastjson測試程式中,編譯出錯,如下:
Error:duplicate files during packaging of APK /home/linc/workspace/lab/FastjsonTestor/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: META-INF/LICENSE.txt
Origin : /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-.android.jar
Origin : /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File : /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-.android.jar
File : /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-.jar
原來LICENSE.txt出現了沖突,根據提示,我們隻要在build.gradle中做些修改将LICENSE.txt剔除出去即可。
android {
compileSdkVersion
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.linc.fastjsontestor"
minSdkVersion
targetSdkVersion
versionCode
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
。。。
參考:
http://stackoverflow.com/questions/22467127/error-duplicate-files-during-packaging-of-apk