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: C:\Users\huangjie\StudioProjects\TestLean\app\libs\fastjson.jar
File2: C:\Users\huangjie\StudioProjects\TestLean\app\libs\httpmime-4.2.4.jar
意思是不同jar包间存在重复的文件,添加以下常见忽略配置于build.gradle
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’
}

本文介绍了解决Android应用打包时遇到的重复文件错误的方法。通过在build.gradle中添加特定的排除规则,可以有效避免因不同依赖包包含相同资源文件而导致的构建失败。
2759

被折叠的 条评论
为什么被折叠?



