Mastering ProGuard with ProGuard GUI - Part 1 (ProGuard with JAR)

8:39 PM 2 Comments

ProGuard is a nice tool that is used to shrink, obfuscate, and optimize Java code. It is part of Android SDK and very useful when applied correctly. ProGuard provides four main features:
  1. Shrinking
  2. Obfuscation
  3. Repackaging
  4. Optimization
First of all, Download ProGuard from this link : ProGuard. It contains proguardgui.jar in lib folder. Run that jar and ProGuard GUI popup. Follow below steps to apply ProGuard to JAR.

  1. Go to Input/Output:Add JAR file using Add input and specify output folder using Add output.
    New JAR will be placed in Output folder. ProGuard uses it to reconstruct the class dependencies that are necessary for proper processing. The library JAR itself always remain unchanged.

  2. Go to Shrinking:It is necessary to reduce the size of APK. It can be more advantageous because large binaries are less likely to be installed in poor network conditions.
    Shrink collects all unused code and it is possible to list all that unused code to file by providing file path in "Print Usage" section.
  3. Go to Obfuscation:Today, there are plenty of tools available to extract the contents of APKs. It is important to obfuscate to protect the code base. ProGuard generates a mapping file that allows to map the stack traces of obfuscated code to actual code. To get mapping file tick "Print mapping" and give path where file will be dumped."Apply Mapping" is useful to reuse the given name mapping that was printed out in a previous obfuscation run of ProGuard. Classes and class members that are listed in the mapping file receive the names specified along with them.

    "Keep package names" is used to keep the given package name from being obfuscated. Give multiple package name with coma separation.

    "Use mixed-case class names" is useful to generate mixed-case class names while obfuscating.

    "Keep additional class names and class members names" is very important to keep classes from being obfuscated,classes like models, interfaces etc. To keep methods out of Obfuscation, add method in added class with valid access modifiers. For example, if you specify public methods, Public methods would not obfuscate by ProGuard.If method name, return type or argument type is not specify, ProGuard will keep all public methods from obfuscation. 

    "Repackage classes" allows ProGuard to take externals  jar and class files and move them to a single package location. For building libraries, it is very helpful to choose simple interface to third party developers when maintaining well structured project in the repository.

  4. Go to Optimization: It is not recommended to use it because of some dalvik version issues and by default Android tool has optimization turned off in ProGuard.

  5. Go to Information: set target to java version used. Tick verbose to write out more information during process. If execution terminated with exception,  this option will print out the entire stack trace instead of just exception message."Print configuration" is useful to write out the entire configuration that has been parsed, with included files and replaced variables. It will generate file in output folder.

  6. Go to Process: It has an output console for displaying the configuration and the messages while processing. Click on Process and it executes ProGuard with the current configuration. New JAR will be placed in folder which is specified at Input/Output section.

Reference :


My name is Karn Shah, I am a software developer living in Ahmedabad,India and my job/hobby is Android. I have been working on the Android platform since 2011 and I hope that sharing what I have learned will help people get proficient in Android faster!


  1. Always I can see the error:

    The output jar is empty. Did you specify the proper '-keep' options?

    How to fix it?