问题描述
在使用Android studio引入第三方jar包,打包时出错
Error:duplicate files during packaging of APK F:\Travel\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/NOTICE.txt
Origin 1: F:\Travel\app\libs\commons-codec-1.6.jar
Origin 2: F:\Travel\app\libs\commons-httpclient-3.1.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude ‘META-INF/NOTICE.txt’
}
}
Error:Execution failed for task ‘:app:packageDebug’.
Duplicate files copied in APK META-INF/NOTICE.txt
File 1: F:\Travel\app\libs\commons-codec-1.6.jar
File 2: F:\Travel\app\libs\commons-codec-1.6.jar
解决思路
- 错误原因是META-INF/NOTICE.txt重复,我就删除掉了引入jar包里面的NOTICE.txt和LICENSE.txt
- 根据提示在build.gradle添加打包选项
packagingOptions {
exclude ‘META-INF/LICENSE.txt‘
exclude ‘META-INF/NOTICE.txt‘
}
时间: 2024-12-18 17:58:29