build.gradle-Error:duplicate files during packagin

本文介绍了解决Android项目中APK打包时遇到的重复文件错误的方法。通过在build.gradle文件中添加特定配置,可以排除引起冲突的META-INF文件,从而避免编译错误。
只需要在Android下的build.gradle加上这个。
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
     当报这样的错的时候   
    Error:duplicate files during packaging of APK E:\studiospace\CheGuan\app\build\outputs\apk\app-debug-unaligned.apk
    Path in archive: META-INF/LICENSE.txt
    Origin 1: E:\studiospace\CheGuan\app\libs\httpcore-4.2.4.jar
    Origin 2: E:\studiospace\CheGuan\app\libs\fastjson-1.2.5.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: E:\studiospace\CheGuan\app\libs\httpcore-4.2.4.jar
    File 2: E:\studiospace\CheGuan\app\libs\fastjson-1.2.5.jar

转载于:https://my.oschina.net/u/2601891/blog/611208

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值