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

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

问题描述

我在一个商业安卓应用程序中工作.我还使用了一些在不同许可类型下获得许可的库,其中一些声明如下:

如果图书馆有带有署名注释的NOTICE"文件,您必须在分发时包含该通知

(例如,其中之一是根据 Apache License 2.0 获得许可的).

有不止一个图书馆.当我使用 gradleAndroid Studio 进行构建时,出现以下构建错误:

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

我现在在互联网和 stackoverflow 上找到的答案建议通过添加到 build.gradle 从打包中删除 license.txt(notice.txt 或其他可能会干扰的文件)归档以下内容:

packagingOptions {排除 'META-INF/DEPENDENCIES.txt'排除 'META-INF/LICENSE.txt'排除 'META-INF/NOTICE.txt'排除元信息/通知"排除元信息/许可证"排除元信息/依赖项"排除 'META-INF/notice.txt'排除 'META-INF/license.txt'排除 'META-INF/dependencies.txt'排除META-INF/LGPL2.1"}

参见例如:Android Studio 0.4 在 APK META-INF/LICENSE.txt 中复制的重复文件

根据这些库的许可(例如Apache License 2.0),许可和通知文件应该包括.>

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

解决方案

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

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

另外,Google 还发布了 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天全站免登陆