Skip to content

Instantly share code, notes, and snippets.

@sreereddymenon
Created August 22, 2016 20:23
Show Gist options
  • Save sreereddymenon/96e376b197784bd3903c8a6067934d4b to your computer and use it in GitHub Desktop.
Save sreereddymenon/96e376b197784bd3903c8a6067934d4b to your computer and use it in GitHub Desktop.
proguard usage
So you have a library defined and you want to run proguard on it when building it to remove unused code and to obfuscate code. Of course you do not want to remove or obfuscate classes/interfaces/enums/methods/fields that are public since these will be called on by the projects that depend on your library.
Here are the rules that you need in your proguard config file:
-keepparameternames
-keep public interface com.mycompany.mylibrary.** {
<methods>;
}
-keep public class com.mycompany.mylibrary.** {
public <init>(...);
public <fields>;
public static <fields>;
public <methods>;
public static <methods>;
}
-keep public enum com.mycompany.mylibrary.** {
public <init>(...);
public <fields>;
public static <fields>;
public <methods>;
public static <methods>;
}
The above is not an exhaustive list of all the rules which you might need but it's a starting point and should suffice for most libraries. If you need to add some more rules you'll need to get a grasp of the proguard rules syntax here: http://proguard.sourceforge.net/manual/usage.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment