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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
In your config file, set up your jars as library jars instead of input jars. This leaves them untouched.
-libjars <path/to/jars>
回答3:
Using proguard maven plugin I do it like that
<inclusion>
<groupId>foo.bar</groupId>
<artifactId>foo-bar</artifactId>
<library>true</library>
<filter>!META-INF/**</filter>
</inclusion>
The
<library>true</library>
lead to the external jar merged into the final jar after the obfuscation. But this might lead to the Manifest being overwritten. I haven't figured out yet how to avoid that the best way.