Skip to content

Reduce App Size

navin9584 edited this page Oct 14, 2022 · 1 revision

changes in android/app/build.gradle file

1. minifyEnabled true

By setting minifyEnabled to true, we are telling proguard to remove all the unused methods, instructions and slim down the classes.dex file.

enabling the proguard in every module of our project we can we are able to reduce the classes.dex file size almost by 50%

2.shrinkResources

“shrinkResources” attribute will remove all the resources, those are not used anywhere in the project. Enable this in your build.gradle file by adding below line:

release{

shrinkResources true

}

3. “resConfigs” attribute will remove all the other localized resources while building the application. In our case, only supports the English language.

While all the support libraries may have localized folders for other languages. Which we don’t need. So, add following line to allow only English resources to be added in APK file.

reduce in kb 96.9 mb to 96.8mb

defaultConfig {

resConfigs "en"
}

4. webp extension images are having less size than png files and also it retains the original image quality.

in saral app when i change it reduce 400kb => reduce 96.8 to 96.4

5. add lines in ### gradle.properties file

android.enableR8.fullMode =true

Clone this wiki locally