Android Proguard warning: can't write resource (Duplicate zip entry)-ThrowExceptions

Exception or error:

I enabled proguard and got:

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])

What does it mean?
Should I exclude something like here?

configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'
}
How to solve:

You are using a library with duplicate files, is a bug in gradle, for solve use this in your project build.gradle

android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude '.readme'
    }
}

###

From Proguard manual:

Warning: can’t write resource … Duplicate zip entry

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.

The standard Android build process automatically specifies the input jars for you. There may not be an easy way to filter them to remove
these warnings. You could remove the duplicate resource files manually
from the input and the libraries.

###

Adding option -ignorewarnings in the proguard config file worked for me. It still gives warning for ‘META-INF/LICENSE.txt’ but build does not fail. But use this option only if you are sure about what are its effects. Follow http://proguard.sourceforge.net/manual/usage.html#ignorewarnings for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *