Proguard in Android

Overview

Proguard is a tool to minify your code, obfuscate your code and to optimize your code. Proguard can reduce the size of your application and also can improve the performance. It can remove unused classes and methods. If Proguard is enabled in your application then it would be difficult to reverse engineer your application because each and every classes you have used in your application is obfuscated.

Do's and Dont's

  • Proguard is disabled by default. If you want to enable Proguard then you have to set minifyEnable true in the release section of buildTypes in gradle.build (Module) file. Then you have to sync the application.
 buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
  • When you enable the Proguard, then you have to define some set of rules in "proguard-rules.pro" otherwise the released apk will cause errors, because the Proguard have obfuscated the values of data used in a class.

Comments

Popular posts from this blog

SSLSocketFactory in Android

Architecture Components in Android

DataBinding in Android