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

When I export an android project with proguard.cfg, all the specified .jar files are also confused. How can I exclude some of the .jars from obfuscation?

+23
source share
3 answers

If you do not want to edit Ant script, you can add -keep proguard.cfg parameters for classes in these external banks. For instance:

-keep class othercode.** { *; } 

Or with a regex containing a negator:

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

The standard Ant script will still merge all the jars mentioned in a single output jar.

+24
source

In your configuration file, configure your banks as library banks instead of input banks. This leaves them untouched.

 -libjars <path/to/jars> 
+6
source

Using the proguard maven plugin. I do it like this.

 <inclusion> <groupId>foo.bar</groupId> <artifactId>foo-bar</artifactId> <library>true</library> <filter>!META-INF/**</filter> </inclusion> 

 <library>true</library> 

leads to the fact that the external bank merges into the final bank after obfuscation. But this can cause the manifest to be overwritten. I have not yet figured out how to avoid this in the best way.

+1
source

Source: https://habr.com/ru/post/1492673/


All Articles