Android Studio proguard
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.
proguard
Android Studio Project
If you have Android Studio Project, you already had proguard file named proguard-rules.pro
At first, there are no description. No description means apply proguard for everything.
If you want to add exceptional, add description follow as example
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
Simple
android { ... buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
… 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)