Duplicate files copied in APK META-INF/LICENSE

版权声明:转载请注明出处 https://blog.csdn.net/h20101988/article/details/64507203

android 项目编译时,出现如下错误:

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

解决方案:
在module(APP) 目录下,修改 build.gradle 文件,添加如下内容:

android{

    .....
    //添加的内容
    packagingOptions {
        exclude 'META-INF/LICENSE'

        //下面的内容可解决类似的错误,如: Duplicate files copied in APK META-INF/DEPENDENCIES 等等,根据报错内容选择添加
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

个人博客:www.hellocodes.cn

猜你喜欢

转载自blog.csdn.net/h20101988/article/details/64507203
今日推荐