How to use ProGuard in Android Studio

 How to use ProGuard in Android Studio :

ProGuard is a Java class file shrinker, optimizer, obfuscator, and preverifier.

Step-1 : To use ProGuard, you can add the following to your build.gradle file:

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

This will enable ProGuard for the release build type and use the default ProGuard configuration file 'proguard-android.txt' as well as a custom configuration file 'proguard-rules.pro'.

Step-2 : You can also specify ProGuard options on the command line when building your project using the ./gradlew command. For example:

./gradlew assembleRelease -Pproguard

This command will build the release version of your app and run ProGuard on it.

You can also configure ProGuard to save the mapping.txt file that is used to map obfuscated class, method, and field names to their original names.

You can refer to the ProGuard manual for more details on how to use and configure ProGuard : https://www.guardsquare.com/en/proguard/manual/index.html

Previous Post Next Post