Swisyn
12/22/2015 - 11:09 AM

Configuration of proguard-rules.pro

Configuration of proguard-rules.pro

Proguard Configuration

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

CodeKeep 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

:books: Best Android Gists

You can see other best Android Gists or offer your just here https://github.com/lopspower/BestAndroidGists :+1:.