Skip to content

Instantly share code, notes, and snippets.

@Swisyn
Forked from lopspower/README.md
Created February 3, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swisyn/c141413eee27138c3c67 to your computer and use it in GitHub Desktop.
Save Swisyn/c141413eee27138c3c67 to your computer and use it in GitHub Desktop.
Configuration of proguard-rules.pro

Proguard Configuration

Twitter

1) Enable Proguard in your build.gradle module :

android {
    //...
    buildTypes {
        release {
            minifyEnabled true // Change value with true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

In that case, all the classes are encrypted.

2) Keep specific classes and methods

You can change your proguard-rules.pro to keep visible specific classes and methods.

-keep classmembers class your.package.classname {
  *; #KEEP ALL
}

Example:

-keep public class com.mikhaellopez.MyClass {
	 public static final <fields>;
	 public <methods>;
}

You can also apply it to a whole package:

-keep class your.package.* {
  *;
}

3) Properties Keep

Code Keep effect
*; KEEP ALL
public static final <fields>; KEEP ALL PUBLIC ATTRIBUTES
public <methods>; KEEP ALL PUBLIC METHODS
public *; KEEP ALL PUBLIC METHODS AND ATTRIBUTES
public void onCreate(...); KEEP SPECIFIC METHOD
<fields>; KEEP ALL FIELDS
<methods>; KEEP ALL METHODS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment