19

我启用了 proguard 并得到:

Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-io-2.4.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-io-2.4.jar:META-INF/NOTICE.txt])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-collections-3.2.1.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-collections-3.2.1.jar:META-INF/NOTICE.txt])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [joda-time-2.7-no-tzdb.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [joda-time-2.7-no-tzdb.jar:META-INF/NOTICE.txt])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-primitives-1.0.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/services/javax.annotation.processing.Processor] (Duplicate zip entry [icepick-processor-2.3.6.jar:META-INF/services/javax.annotation.processing.Processor])
Warning:can't write resource [.readme] (Duplicate zip entry [classes.jar:.readme])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-lang-2.6.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-lang-2.6.jar:META-INF/NOTICE.txt])

这是什么意思?我应该排除类似这里的东西吗?

configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'
}
4

3 回答 3

30

您正在使用带有重复文件的库,这是 gradle 中的一个错误,用于解决在您的项目 build.gradle 中使用此问题

android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude '.readme'
    }
}
于 2015-06-03T02:06:44.277 回答
1

来自Proguard 手册

警告:无法写入资源...重复的 zip 条目

您的输入 jar 包含多个具有相同名称的资源文件。ProGuard 像往常一样继续复制资源文件,跳过任何以前使用过的名称的文件。再一次,警告可能表明存在一些问题,因此建议删除重复项。一种方便的方法是在输入 jar 上指定过滤器。没有选项可以关闭这些警告。

标准的 Android 构建过程会自动为您指定输入 jar。可能没有简单的方法来过滤它们以删除这些警告。您可以从输入和库中手动删除重复的资源文件。

于 2016-07-05T06:46:33.973 回答
0

-ignorewarnings在 proguard 配置文件中添加选项对我有用。它仍然对“META-INF/LICENSE.txt”发出警告,但构建不会失败。但仅当您确定其效果时才使用此选项。关注http://proguard.sourceforge.net/manual/usage.html#ignorewarnings了解更多信息。

于 2015-12-10T16:26:26.827 回答