Skip to content
Proguard Demo for the Cincy Android Dev Group
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Proguard Demo

Proguard Demo for the Cincy Android Dev Group by Andy McSherry

Useful Links


  • Security
  • Protect IP
  • Reduce APK Size
  • Optimization
  • Remove Logging



  • Be very specific
  • Don't assume proguard will catch it

First Steps

  1. Create proguard.cfg
  2. Add proguard.config=proguard.cfg to
  3. To obfuscate in debug builds, edit your -debug-obfuscation-check target to look like this:
<target name="-debug-obfuscation-check">
        <!-- yes, we want to obfuscate in debug too!!!! -->
        <condition property="proguard.enabled" value="true" else="false">
                <isset property="proguard.config" />
        <if condition="${proguard.enabled}">
                <!-- Secondary dx input (jar files) is empty since all the
                     jar files will be in the obfuscated jar -->
                <path id="out.dex.jar.input.ref" />

Initial Template

#Remove all the injar/outjar/libraryjar junk, the android ant script takes care of this

-repackageclasses ''
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends
-keep public class * extends
-keep public class * extends
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;

-keepclassmembers class **.R$* {
    public static <fields>;


-keep public class * extends
-keep public class * extends

3rd Party Libraries

-keep class android.** {*;}
-keep class** {*;)
-keep class** {*;}

Removing Logging

-assumenosideeffects class android.util.Log {
    public static *** e(...);
    public static *** w(...);
    public static *** wtf(...);
    public static *** d(...);
    public static *** v(...);


-keepnames class * implements

-keepclassmembers class * implements {
    static final long serialVersionUID;
    private static final[] serialPersistentFields;
    !static !transient <fields>;
    !private <fields>;
    !private <methods>;
    private void writeObject(;
    private void readObject(;
    java.lang.Object writeReplace();
    java.lang.Object readResolve();

Click Methods

-keepclassmembers class * {

public void *ButtonClicked(android.view.View);


Native Methods

-keepclasseswithmembernames class * {
    native <methods>;

Deobfuscating Stack Traces

  • Save mapping.txt from any build released
  • is in sdk.dir/tools/proguard/bin
  • No free plans, great product though.
  • Free plans, but very limited. Open source projects have more robust free plans.
You can’t perform that action at this time.