Obfuscation in Android Studio

  • Basic Obfuscation

To obfuscate code in Android studio just go to your build.gradle file in your Android Studio project:

enter image description here

Change the minifyEnabled property from false to true

enter image description here

This is a basic Obfuscation.

After generating the apk you can see the obfuscation result by decompiling the apk with any software. This page could help you:

http://www.decompileandroid.com/

In the obfuscation result you will see classes with name: a,b,c….

enter image description here

And the obfuscation variables and methods will have also names like aa,c,ac…

enter image description here

  • Normal obfuscation:

To obfuscate the code in a more complex form you could go to your root directory app and create a .pro file. For example in the following picture I have created the file: proguard-rules-new.pro. In the same directory you should see a file called proguard-rules.pro

enter image description here

Now add the file you have created to the build.gradle file

enter image description here

And edit the .pro file you have create with your own custom proguard rules

enter image description here

Leave a Comment