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

混江龙づ霸主 提交于 2019-11-30 04:38:15

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.

In your config file, set up your jars as library jars instead of input jars. This leaves them untouched.

-libjars <path/to/jars>
haferblues

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!