Android Studio proguard


proguard is Android tool to uglify source codes when compiling.
In Java, decompile is very easy and everyone can see source codes from apk or jar file.

Android Studio Project

If you have Android Studio Project, you already had proguard file named
At first, there are no description. No description means apply proguard for everything.

If you want to add exceptional, add description follow as example

-keepattributes *Annotation*
-keepattributes Signature

-dontwarn com.squareup.okhttp.**

Apply proguard

By default, proguard is not applied.
To apply, we need to add some descriptions in build.gradle


android {
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

… is compileSdkVersion, buildToolVersion, defaultConfig etc…
The important part is buildTypes, add release

Name Description
minifyEnabled Whether we make minify enable or not
proguardFiles proguard file path

(if you want to apply proguard to debug version, add debug)