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

rfgamaral picture rfgamaral · May 3, 2013 · Viewed 33.8k times · Source

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!

Answer

Alejandro Colorado picture Alejandro Colorado · May 16, 2013

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.