The ProGuard tool shrinks and optimizes your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The end result is a smaller APK
that's more difficult to reverse engineer, something that's particularly important if your app has access to sensitive information.
ProGuard runs automatically when you build your app in release mode. To build a release version of your app, you need to enable the minifyEnabled
property in your project's module-level build.gradle
file and make sure buildTypes
is set to release
. For example:
android { ... buildTypes { //The buildTypes element controls whether your app is built in debug or release mode// release { //In this example, we're building a release version of our app so we can run ProGuard. If your build.gradle file contains the debug attribute, then make sure you remove it so it doesn't prevent ProGuard from running// ...