android - Proguard 警告 "can' t 写入资源 [META-INF/MANIFEST.MF](重复的 zip 条目)”

标签 android warnings proguard android-support-library

我正在使用 IntelliJ 并在 Debug模式下运行 Proguard,但我似乎无法摆脱以下警告:

ProGuard: [MyApplication] Warning: can't write resource [META-INF/MANIFEST.MF] 
(Duplicate zip entry [android-support-v13.jar:META-INF/MANIFEST.MF])

这个项目有几个模块,android-support-v13.jar 正在其中两个上使用。我认为这是问题所在,所以我从 libs 文件夹中删除了该库,将其添加为项目库并将依赖项添加到两个模块。那没有解决任何问题,警告仍然存在,我不明白为什么。

我知道这些警告不会影响任何事情,但干净的构建是一个快乐的构建!

最佳答案

可能是“proguard.cfg”问题。它是否包括任何“-injars”?如果您的项目包含另一个项目作为库,则可以处理两次 jar。你能发布你的“proguard.cfg”吗?

摘自 http://proguard.sourceforge.net/index.html#manual/troubleshooting.html :

Your input jars contain multiple resource files with the same name. ProGuard continues copying the resource files as usual, skipping any files with previously used names. Once more, the warning may be an indication of some problem though, so it's advisable to remove the duplicates. A convenient way to do so is by specifying filters on the input jars. There is no option to switch off these warnings.

选项 #1:

由于您无法发布“-injars”,请检查它们是否包含“android-support-v13.jar”或项目中包含的库,该库本身也包含“android-support-v13.jar”。

假设您在 IntelliJ IDEA 中使用 Ant 构建,您不能添加 -injars、-outjars 或 -libraryjars 选项; Ant 脚本已经为您做到了。

选项 #2:

虽然警告是无害的,但干净的构建是一个快乐的构建,所以试试吧:

http://web.archive.org/web/20160206204259/http://www.dancartoon.com/2012/01/14/fixing-proguard-warning-cant-write-resource-meta-infmanifest-mf/

https://gist.github.com/paulpv/4439012

选项 #3:

在每个“-injars”命令之后包含 (!META-INF/MANIFEST.MF)

-injars library.jar(!META-INF/MANIFEST.MF)

选项 #4: Android Proguard Duplicate Definition

Fixed this by moving the 3rd party libraries to another directory, in my case 'lib'. Then added

-injars lib/jmdns.jar 

to the proguard.cfg file.

选项 #5: Android - Proguard duplicate zip entry error

如果您的 Proguard 配置文件包含以下行,请将其删除:

-injars bin/classes

选项 #6: Android obfuscate app using proguard keeps obfuscating library jars - or is it?

I found another way to make Proguard leave library jars alone was to ask it to preserve their package names, eg:

-keep class javax.** { *; } -keep class org.** { *; } -keep class twitter4j.** { *; }

选项 #7:

一个奇怪的解决方案(删除 src 文件夹中的 META-INF 文件夹)类似于 here .

关于android - Proguard 警告 "can' t 写入资源 [META-INF/MANIFEST.MF](重复的 zip 条目)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16357959/

相关文章:

android - 如何将字符串值更改为斜体

java - 在 RecyclerView 中滚动时如何使relativelayout消失

c++ - 头文件中的错误 C4430

android - 我如何从android中的另一个选项卡调用一个选项卡?

c - 摆脱警告 : implicit declaration of function ‘fileno’ in flex

Java:未经检查的转换的类型安全警告

android - 不要使用 Proguard 优化特定的类路径

java - 使用 ProGuard 后异常跟踪不显示私有(private)方法的行号

android - 添加proguard时出错

java - 使用 Android 的 AccountManager 添加自定义帐户