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.

Similar Reads

What is Proguard?

Proguard is a java tool that is present in Android and it is used to reduce your app size. It is a free tool that will help you to reduce your app size by 8.5 %. Proguard will convert your app’s code into optimized Dalvik bytecode. The process for conversion is as follows:...

What are the Uses of Proguard?

Proguard will obfuscate your code and rename your code. In this process, it will rename your files of different java classes. This will make your app more secure and difficult to reverse engineer. It will remove unused code snippets inside your code and optimize your code. Using proguard will reduce your app size by 8.5 %. Proguard will shrink the resources inside your app which is not being used in your app. The usage of proguard will reduce your app size and make your code inline. This will make your app faster and less in size....

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....

Custom Rules in Proguard

When we use proguard inside our application it will automatically remove some modal classes which are required inside our app. So to avoid removing these files we have to add some custom rules inside our application....

Disadvantages of Using Proguard

...

Conclusion

...