How to use Proguard inside your app?
To enable proguard inside your app, navigate to the app > gradle Scripts > Open build.gradle file. Inside that gradle file you will get to see below lines of code in your file inside the release section. Change minifyEnabled from false to true. This will activate your proguard with the proguard file.
buildTypes {
release {
// make change here
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt’), ‘proguard-rules.pro’
}
}
You will find this set of code inside your release block. This means that Proguard will be activated for your release app only.
How to Use Proguard to Reduce APK Size in Android?
App size matters a lot when building any application. If the app size is larger most of the users will not download your app due to its huge size. The large app size will cost your user huge data and he will also require disk space to install your application. So to reduce the size of APK proguard is one of the important java tools which is used to reduce the size of your APK. In this article we will take a look at the topics mentioned below:
- What is Proguard?
- What are the uses of Proguard?
- How to use proguard inside your app?
- What are the disadvantages of using Proguard?
- Custom rules in Proguard.