Duplicate files copied in APK META-INF/LICENSE异常冲突解决
来源:互联网 发布:photosynth替代软件 编辑:程序博客网 时间:2024/06/06 11:37
最近在引进一个开源项目,ColorfulNews遇到这样一个问题:
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
File1: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.7.2\84ffa765dd258dbab8695963c41308b054f3a1cb\jackson-databind-2.7.2.jar
File2: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.7.0\19f42c154ffc689f40a77613bc32caeb17d744e3\jackson-annotations-2.7.0.jar
File3: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.7.2\8b8310381b690e317f5f0574e9b2dd7034778b4c\jackson-core-2.7.2.jar
把它理解成证书冲突吧,就像我们有时候引用jar包一样,里面有重复的class,需要在gradle文件中加如下引用,解决这个问题
packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/license.txt'}
很多人不明白为什么,证书冲突也不可以,stackflow上的解释:In Android Gradle builds, you're not permitted to include the same file with the same path more than once in the output. In your build, there were two META-INF/DEPENDENCIES
files coming from different places. Since you don't need this file at all in your application, the simplest thing to do is to tell the build system to ignore it altogether, which is what this exclude
directive does.
在gradle构建中,不允许引入一个相同的文件(拥有相同的路径)2次。在构建中,如果有2个META-INF/DEPENDENCIES 文件来自不同的路径。如果在应用中不需要这个文件了,最简单的方法是告诉构建系统忽略全部这个,通过用 exclude指令来做这件事
There's also a pickFirst
directive to tell the build system to keep one of the copies; there's a tiny amount of detail on that in Android Gradle plugin 0.7.0: "duplicate files during packaging of APK".
还有一个指令pickFirst指令告诉构建系统保持一份拷贝,这里有一个细节文章详见 Android Gradle plugin 0.7.0: "duplicate files during packaging of APK".
Android builds in Gradle are rather strict about duplicate files, which can make life difficult. There's a similar problem if you include the same Java class more than once, where you get the "Multiple dex files define" error (see Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat) for a typical example).
Other build systems are more lenient. It's typical in Java that if you include the same class more than once in a classpath, for example, the first copy it sees is the one that's used; duplicates after that are ignored. This is in most cases easier to deal with, but it has a couple problems. The biggest one is that there can be subtle errors if multiple different versions of a file creep into the build without you knowing -- it can be difficult to figure out what's going on. When you do figure it out, you can usually solve it by juggling the order in which things are included to make sure the one you want makes it to the final output, but in very complex builds, this can be difficult to achieve, and it can happen that doing seemingly unrelated things like including new libraries in your project can upset the ordering and lead to a lot of woe.
For that reason, Gradle has the philosophy of not relying on ordering of things to determine "winners" in the game of resolving duplicates, and it forces the developer to make all dependencies explicit. Android's implementation of its build system on top of Gradle follows that philosophy.
- Duplicate files copied in APK META-INF/LICENSE异常冲突解决
- Android解决Duplicate files copied in APK META-INF/LICENSE
- 解决Duplicate files copied in APK META-INF/LICENSE
- Duplicate files copied in APK META-INF/license.txt
- Duplicate files copied in APK META-INF/LICENSE.txt
- Duplicate files copied in APK META-INF/LICENSE.txt
- Duplicate files copied in APK META-INF/LICENSE.txt
- Duplicate files copied in APK META-INF/license.txt
- Duplicate files copied in APK META-INF/LICENSE的解决方案
- Duplicate files copied in APK META-INF/LICENSE
- Duplicate files copied in APK META-INF/LICENSE
- DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
- Duplicate files copied in APK META-INF/LICENSE.txt解决方式
- android studio---Duplicate files copied in APK META-INF/LICENSE.txt 错误解决
- Duplicate files copied in APK META-INF/解决方式
- Duplicate files copied in APK META-INF/
- Android Studio 错误 Duplicate files copied in APK META-INF/LICENSE.txt
- android stuido 编译报 Duplicate files copied in APK META-INF/LICENSE.txt 问题
- 单链表反转
- Material Design 兼容性控件学习
- 【bzoj3328】PYXFIB 题解
- HDU
- (待更新理解)(数值过大素数计数模版)HDU 5901 Count primes
- Duplicate files copied in APK META-INF/LICENSE异常冲突解决
- ACM ArabellaCPC 2015 E题.二分or离散化
- HTTPweb服务器——HTTP整体设计框架
- java 网络编程(三)
- idea中war和war exploded的区别及修改jsp必须重新启动tomcat才能生效的问题(转)
- zy专区
- mongodb,redis,hbase 三者都是nosql数据库,他们的最大区别和不同定位
- scrapy 开发环境搭建
- 经典递归问题--汉诺塔