Android问题集锦之四十八:Error:duplicate files during packaging of APK

端午小长假最后一天,大雨。只好在家里鼓捣自己喜欢的代码了。

在将dom4j.jar也加入fastjson测试程序中,编译出错,如下:

Error:duplicate files during packaging of APK /home/linc/workspace/lab/FastjsonTestor/app/build/outputs/apk/app-debug-unaligned.apk
    Path in archive: META-INF/LICENSE.txt
    Origin 1: /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-1.1.45.android.jar
    Origin 2: /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-1.6.1.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'META-INF/LICENSE.txt'
      }
    }
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
    File 1: /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-1.1.45.android.jar
    File 2: /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-1.6.1.jar

原来LICENSE.txt出现了冲突,根据提示,我们只要在build.gradle中做些修改将LICENSE.txt剔除出去即可。

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.linc.fastjsontestor"
        minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    。。。

参考:
http://stackoverflow.com/questions/22467127/error-duplicate-files-during-packaging-of-apk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值