In
Android Studio, it is possible to use
ProGuard to minify and obfuscate the Java source code from decompilation. The settings are different from the
Eclipse ADT as Android Studio uses the
Gradle build system. But still as straightforward provide you know where and what to change. At the minimum, you only need to enable ProGuard but sometimes it may be necessary to define classes that you do not want ProGuard to obfuscate - this can be done in a ProGuard rules file. The following steps illustrate these two tasks.
Enable ProGuard
- In Android Studio, open up an Android project.
- Change to Project View.
- Edit the app's build.gradle file.
Note: make sure the correct build.gradle file is edited. Typically, it is [Android project]/app/build.gradle.
- Change the following line:
minifyEnable false
to
minifyEnable true
Set ProGuard Rules(optional)
- In Project View, select the proguard-rules.pro file.
Note: Typically it is [Android project]/app/proguard-rules.pro.
- Add in the following lines to tell ProGuard not to obfuscate certain classes.
-keepclassmembers class com.dom925.xxxx {
Now when a release build is generated using Android Studio, the app will be obfuscated.