Last active
December 10, 2015 13:08
-
-
Save paulpv/4439012 to your computer and use it in GitHub Desktop.
Fixing ProGuard "Warning: can't write resource [META-INF/MANIFEST.MF]" Updated version of http://www.dancartoon.com/2012/01/14/fixing-proguard-warning-cant-write-resource-meta-infmanifest-mf/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="custom_rules"> | |
<!-- | |
Suppress "Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])". | |
Per http://www.dancartoon.com/2012/01/14/fixing-proguard-warning-cant-write-resource-meta-infmanifest-mf/ | |
Target "-obfuscate" copied from ${sdk.dir}/tools/ant/build.xml v21. | |
--> | |
<target name="-obfuscate"> | |
<if condition="${proguard.enabled}"> | |
<then> | |
<property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard" /> | |
<property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/original.jar" /> | |
<property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar" /> | |
<!-- input for dex will be proguard's output --> | |
<property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}" /> | |
<!-- Add Proguard Tasks --> | |
<property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar" /> | |
<taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}" /> | |
<!-- Set the android classpath Path object into a single property. It'll be | |
all the jar files separated by a platform path-separator. | |
Each path must be quoted if it contains spaces. | |
--> | |
<pathconvert property="project.target.classpath.value" refid="project.target.class.path"> | |
<firstmatchmapper> | |
<regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
<identitymapper/> | |
</firstmatchmapper> | |
</pathconvert> | |
<!-- Build a path object with all the jar files that must be obfuscated. | |
This include the project compiled source code and any 3rd party jar | |
files. --> | |
<path id="project.all.classes.path"> | |
<pathelement location="${preobfuscate.jar.file}" /> | |
<path refid="project.all.jars.path" /> | |
</path> | |
<!-- Set the project jar files Path object into a single property. It'll be | |
all the jar files separated by a platform path-separator. | |
Each path must be quoted if it contains spaces. | |
--> | |
<!-- | |
Old: | |
<pathconvert property="project.all.classes.value" refid="project.all.classes.path"> | |
New: | |
--> | |
<pathconvert property="project.all.classes.value" refid="project.all.jars.path" pathsep=" "> | |
<firstmatchmapper> | |
<!-- | |
Old: | |
<regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
<identitymapper/> | |
New: | |
--> | |
<regexpmapper from='^([^ ]*)( .*)$$' to='-injars "\1\2"(!META-INF/MANIFEST.MF)'/> | |
<regexpmapper from='(.*)' to='-injars \1(!META-INF/MANIFEST.MF)'/> | |
</firstmatchmapper> | |
</pathconvert> | |
<!-- Turn the path property ${proguard.config} from an A:B:C property | |
into a series of includes: -include A -include B -include C | |
suitable for processing by the ProGuard task. Note - this does | |
not include the leading '-include "' or the closing '"'; those | |
are added under the <proguard> call below. | |
--> | |
<path id="proguard.configpath"> | |
<pathelement path="${proguard.config}"/> | |
</path> | |
<pathconvert pathsep='" -include "' property="proguard.configcmd" refid="proguard.configpath"/> | |
<echo>proguard: $${project.all.classes.value}=${project.all.classes.value}</echo> | |
<mkdir dir="${obfuscate.absolute.dir}" /> | |
<delete file="${preobfuscate.jar.file}"/> | |
<delete file="${obfuscated.jar.file}"/> | |
<jar basedir="${out.classes.absolute.dir}" | |
destfile="${preobfuscate.jar.file}" /> | |
<proguard> | |
-include "${proguard.configcmd}" | |
-include "${out.absolute.dir}/proguard.txt" | |
-injars ${preobfuscate.jar.file} | |
${project.all.classes.value} | |
-outjars "${obfuscated.jar.file}" | |
-libraryjars ${project.target.classpath.value} | |
-dump "${obfuscate.absolute.dir}/dump.txt" | |
-printseeds "${obfuscate.absolute.dir}/seeds.txt" | |
-printusage "${obfuscate.absolute.dir}/usage.txt" | |
-printmapping "${obfuscate.absolute.dir}/mapping.txt" | |
</proguard> | |
</then> | |
</if> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still doesn't solve the problem for me
Here's what ProGuard is trying to do:
-obfuscate: [delete] Deleting: /home/username/myproject/ActionBarSherlock/library/bin/proguard/original.jar [delete] Deleting: /home/username/myproject/ActionBarSherlock/library/bin/proguard/obfuscated.jar [jar] Building jar: /home/username/myproject/ActionBarSherlock/library/bin/proguard/original.jar [proguard] ProGuard, version 4.7 [proguard] Reading program jar [/home/username/myproject/ActionBarSherlock/library/bin/proguard/original.jar] [proguard] Reading program jar [/home/username/myproject/ActionBarSherlock/library/libs/android-support-v4.jar] [proguard] Reading library jar [/home/username/Software/Android/android-sdk-linux/platforms/android-18/android.jar] [proguard] Preparing output jar [/home/username/myproject/ActionBarSherlock/library/bin/proguard/obfuscated.jar] [proguard] Copying resources from program jar [/home/username/myproject/ActionBarSherlock/library/bin/proguard/original.jar] [proguard] Copying resources from program jar [/home/username/myproject/ActionBarSherlock/library/libs/android-support-v4.jar] [proguard] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [android-support-v4.jar:META-INF/MANIFEST.MF])