How can I exclude external .jar from obfuscation by Proguard (Android project)?

alex2k8 picture alex2k8 · Dec 17, 2010 · Viewed 22.8k times · Source

When I export android project with proguard.cfg, all referenced .jar files are obfuscated as well. How can I exclude some of that .jars from obfuscation?

Answer

Eric Lafortune picture Eric Lafortune · Dec 22, 2010

If you don't want to edit the Ant script, you can add -keep options to proguard.cfg for the classes in those external jars. For instance:

-keep class othercode.** { *; }

Or with a regular expression containing a negator:

-keep class !mycode.** { *; }

The standard Ant script will still merge all referenced jars in the single output jar though.