Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

android - Proguard warnings "can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry)"

I'm using IntelliJ and running Proguard in debug mode but I can't seem to get rid of warnings such as:

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

This project has a couple of modules and android-support-v13.jar is being used on 2 of them. I thought that was the issue so I removed that library from the libs folder, added it as a project library and added the dependency to both modules. That didn't solve anything, the warning persists and I don't understand why.

I know these warnings don't affect anything but a clean build is a happy build!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Possibly a 'proguard.cfg' problem. Does it include any '-injars'? If your project includes another project as a library, jars can be processed twice. Could you post your 'proguard.cfg'?

Extract from 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.

OPTION #1:

As you can't post your '-injars', check if they include either 'android-support-v13.jar' or the library included in your project which itself also includes 'android-support-v13.jar'.

Assuming you are building with Ant inside IntelliJ IDEA, you mustn't add -injars, -outjars, or -libraryjars options; the Ant script already does that for you.

OPTION #2:

Although the warnings are harmless, a clean build is a happy build, so try:

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

and

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

OPTION #3:

Include (!META-INF/MANIFEST.MF) after each '-injars' command

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

OPTION #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.

OPTION #5: Android - Proguard duplicate zip entry error

If your Proguard config file includes the following line, remove it:

-injars bin/classes

OPTION #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.** { *; }

OPTION #7:

A weird solution (deleting META-INF folder in src folder) to something similar here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...