Proguard: keep options behaving differently with Shrink and Obfuscate
posted 2 years ago
I am exploring the use of Proguard for my web application. I am primarily interested in shrinking and obfuscating my Applets. What I observed was that the -keep options behave differently with SHRINK and OBFUSCATE options.
For Example, my config file contains the following options to enable shrink and obfuscate and disable optimize and preverify:
The only keep option that
None of the classes in my input jar extend the Driver class
On running this I get the following exception:
After that I change my config file to remove the # that is uncomment the -dontshrink option. This means that I am instructing Proguard to only obfuscate my input jar. In this case everything works fine and I am able to get an obfuscated JAR. The package names and class names have been changed in the obfuscated JAR. All the classes from input JAR were present in the obfuscated JAR.
In an attempt to understand the problem with SHRINK, I
Removed the comment from -dontobfuscate, so as not to obfuscate
Commented the above keep option and the and added the following keep condition:
In this case I am only Shrinking the code. On running this I was able to get an output JAR with only one class that was mentioned in the above keep option.
This makes me to believe that
in case of SHRINK, Proguard shrinks only those classes that match the keep conditions
in case of OBFUSCATE, Proguard obfuscates those classes that don't match the keep conditions
Is this a known behavior or I am missing something.
If this is a known behavior, then how do we make Proguard to SHRINK and OBFUSCATE same set of classes with a single configuration.