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

后端 未结 5 1285
一整个雨季
一整个雨季 2020-11-30 02:52

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

ProGuard: [         


        
相关标签:
5条回答
  • 2020-11-30 03:33

    I used packagingOptions with exclude in build.gradle, and I have same issues with you.

    You can fix it using this.

    packagingOptions { 
        pickFirst 'META-INF/services/javax.annotation.processing.Processor'
        pickFirst 'META-INF/DEPENDENCIES.txt'
        pickFirst 'META-INF/DEPENDENCIES'
        pickFirst 'META-INF/LICENSE.txt'
        pickFirst 'META-INF/LICENSE'
        pickFirst 'META-INF/NOTICE.txt'
        pickFirst 'META-INF/NOTICE'
        pickFirst 'META-INF/LGPL2.1'
    }
    

    Replace pickFirst with exclude.

    0 讨论(0)
  • 2020-11-30 03:35

    Don't reference the support library by including its jar directly; when you do this, the build system can't disambiguate between multiple versions of it, and you get errors of this type. Include it by referencing its Maven coordinates:

    dependencies { compile 'com.android.support:support-v13:X.X.X' } where X.X.X is the proper version number based on what API you're compiling against. If you include this dependency via the UI at Project Structure > (your module) > Dependencies > + Button > Library dependency it will help you choose the right version number.

    You may also find it convenient to include other dependencies via Maven coordinates instead of wrangling their jars; that same library dependency UI has a search function to help you find libraries.

    be sure to remove this library from the libs or any other folder it was present inside

    0 讨论(0)
  • 2020-11-30 03:36

    add -dontwarn to proguard.cfg to ignore warnings

    0 讨论(0)
  • 2020-11-30 03:46

    The best solution I found was to copy the -obfuscate target from /tools/ant/build.xml into your project's custom_rules.xml. Then the only block that needs to be changed is:

    <pathconvert property="project.all.classes.value" refid="project.all.classes.path">
        <firstmatchmapper>
             <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"(!META-INF/MANIFEST.MF)'/>
             <identitymapper/>
        </firstmatchmapper>
    </pathconvert>
    

    The only added bit is (!META-INF/MANIFEST.MF). This will exclude all the manifest files, which won't be copied in to the final APK anyway.

    0 讨论(0)
  • 2020-11-30 03:51

    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.

    0 讨论(0)
提交回复
热议问题