如何解决“在APK META-INF / *中复制的重复文件” [英] How do I resolve "Duplicate files copied in APK META-INF/*"

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

问题描述

我正在一个商业的Android应用程序工作。
我还使用了一些在不同许可证类型下许可的库,其中一些声明如下:
$ b

如果库有一个NOTICE文件您必须在发布时注明此通知



(例如,其中一个许可证位于 Apache许可证2.0 下) 。



有多个库。当我使用 gradle Android Studio 进行构建时,我得到以下构建错误:

  *出错:
任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。
> com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / license.txt中复制的重复文件

直到现在我在internet和stackoverflow上发现的答案建议从包装中删除license.txt(notice.txt或其他可能干扰此类问题的文件) build.gradle 文件如下:

  packagingOptions {
排除'META-INF / DEPENDENCIES.txt'
排除'META-INF / LICENSE.txt'
排除'META-INF / NOTICE.txt'
排除'META-INF / NOTICE'
排除'META-INF / LICENSE'
排除'META-INF / DEPENDENCIES'
排除'META-INF / notice.txt'
排除'META-INF /许可证。 txt'
排除'META-INF / dependencies.txt'
排除'META-INF / LGPL2.1'
}

请参阅: Apache许可证2.0 ),许可证和通知文件应该是 >包含



我的问题:如何添加多个与许可有关的文件(例如 license.txt notice.txt 等)从gradle到我的项目,以符合许可证(技术细节:)许可证文本将被连接)?

解决方案

如果您只有一个使用名称 license.txt (阅读:所有 license.txt 副本相同):

  packagingOptions {
pickFirst'META-INF / license.txt'
}

否则,谷歌也发布了一个Gradle插件来管理依赖关系许可证。请参阅此处。我没有尝试,但它看起来能够聚合每个依赖项,甚至生成显示所有这些许可证的活动。


I am working at a commercial android application. I am also using some libraries licensed under different license types some of them stating the following:

If the library has a "NOTICE" file with attribution notes, you must include that NOTICE when you distribute

(One of them is licensed under Apache License 2.0 for example).

There is more than one library. When I do the build with gradle or with Android Studio I obtain the following build error:

* What went wrong:
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

The answers that I found until now on the internet and stackoverflow suggest to remove the license.txt(notice.txt or other files that could interfere like this) from packaging by adding to build.gradle file the following:

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'
}

See for example: Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt

According to the license of those libraries(Apache License 2.0 for instance), the license and notice files should be included.

My question: How can I add multiple files related to licensing(such as license.txt, notice.txt etc) from gradle into my project in order to be compliant with the licenses(technical detail: licences texts will be concatenated)?

解决方案

There is a solution if you have only one license using the name license.txt (read: all license.txt copies are identical):

packagingOptions {
   pickFirst  'META-INF/license.txt'
}

Otherwise, Google also released a Gradle plugin to manage dependencies licenses. See here. I didn't try it, but it looks like it's capable of aggregating every dependency, and even generating an activity displaying all of those licenses.

这篇关于如何解决“在APK META-INF / *中复制的重复文件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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