在Gradle构建时复制在APK META-INF中复制的文件 [英] Duplicate Files copied in APK META-INF when Gradle building

查看:72
本文介绍了在Gradle构建时复制在APK META-INF中复制的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在环视这里发布的一些关于这个错误的答案,但没有运气。我希望澄清一下发生了什么。我的错误如下:


错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / maven / commons-io / commons-io / pom.xml中复制的重复文件
File1:/home/colin/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar
File2:/home/colin/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar


我已经完成了

  packagingOptions {
排除'META-INF / DEPENDENCIES'
排除'META-INF / LICENSE'
排除'META-INF / LICENSE.txt'
排除'META-INF / license.txt'
排除'META-INF / NOTICE'
排除'META-INF / NOTICE.txt'
排除'META-INF / notice.txt'
排除'META-INF / ASL2 .0

应用程序>中; build.gradle 文件,但问题仍然存在。有其他地方我应该把这个,或者也许只是删除一些文件?或者也许我已经排除了太多的文件 - 我应该省略一些这些行,如果是的话,哪些?我也尝试将依赖关系移动到顶部,高于 Android 无济于事。

此外,我是一个对这些帖子中给出的一些建议很困惑。 排除 PickFirst 之间的操作区别是什么?它们似乎可以互换,但表达了非常不同的想法。看起来我需要在上传到应用商店时包含许可证,所以如果我为了让应用程序进行编译而将其排除在外,那么在准备好上传后,我会在什么时候将其包含在内?我希望有人能够对这里发生的事情有更多的了解。

解决方案

我必须将以下行添加到 packagingOptions {}

  exclude'META-INF / maven / commons-io / commons -io / pom.xml'
排除'META-INF / maven / commons-io / commons-io / pom.properties'

我的问题很愚蠢,当包含排除'META-INF / maven / commons-io / commons-io / pom.xml'时,我得到一个 非常相似的错误到第一个,但实际上是不同的。添加排除'META-INF / maven / commons-io / commons-io / pom.properties'终于使一切正常。仍然不知道为什么我必须采取这些步骤。


I've been looking around at some of the answers posted here about this error but have had no luck. I'm hoping to get some clarification about what's going on. my error is as follows:

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/maven/commons-io/commons-io/pom.xml File1: /home/colin/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar File2: /home/colin/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar

I've done

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}

in the app > build.gradle file, but the problem persists. Is there somewhere else I should put this, or perhaps just delete some file? Or perhaps I've excluded too many files - Should I omit some of these lines, and if so which ones? I also tried moving the dependencies in to the top, above Android to no avail.

Furthermore I'm a little confused about some of the advice given in these posts. What is the operating difference between Exclude and PickFirst? They seem to be interchangeable but express very different ideas. It seems I'm required to include a license when uploading to the app store, so if I'm excluding it here in order to get the app to compile, where do I include it later on when I'm ready to upload? I hope someone can shed some more light on what's going on here.

解决方案

I had to add the following lines to packagingOptions {}

exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'

My problem was pretty foolish; when including exclude 'META-INF/maven/commons-io/commons-io/pom.xml' I got an error that looked very similar to the first one, but was in fact different. adding exclude 'META-INF/maven/commons-io/commons-io/pom.properties' finally got everything working. Still not sure why exactly I have to take these steps though.

这篇关于在Gradle构建时复制在APK META-INF中复制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆