最近在项目中遇到一个很怪的问题,在项目中引入个两个三方包的时出现了包冲突(引入的两个包是fastjson-1.2.5.jar和httpmime-4.1.3.jar),编译时报的错误如下代码:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE.txt
File1: D:\HerVillage_WrokSpace\HerVillage\app\libs\httpmime-4.1.3.jar
File2: D:\HerVillage_WrokSpace\HerVillage\app\libs\fastjson-1.2.5.jar
解决办法
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'
}
}
网友评论