美文网首页
Android Studio 编译时报错:Duplicate f

Android Studio 编译时报错:Duplicate f

作者: mm_cuckoo | 来源:发表于2017-05-27 16:21 被阅读35次

    最近在项目中遇到一个很怪的问题,在项目中引入个两个三方包的时出现了包冲突(引入的两个包是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'
        }
    }
    

    相关文章

      网友评论

          本文标题:Android Studio 编译时报错:Duplicate f

          本文链接:https://www.haomeiwen.com/subject/bupqfxtx.html