APK Size is the most important for our Mobile Devices. I personally love the small APK size Applications. APK Size indicates how fast it loads your app. Overall, it will impact the performance of the APP. While Developing the Application, we should consider some points to reduce our APK size.
- Remove Unused Resource
In the place of JPEGs, and PNGs images, use vector drawable. Some default icons are already present in Android Vector Drawable.
Or WebP is another famous image format which is developed by Google. This image format generally focuses on image quality and optimisation. Rather than using images in PNG and JPEG format, the WebP image format is highly preferable because of its quality.
2. Using Lint
Lint helps in generating warnings or unused code inside the application. So this can help in removing the same. Resolve the warnings and then try to commit the code.
5. Use of proguard
The other use of proguard is as It helps reduce the application size by removing unused classes and methods and making your code tough to reverse engineer.
6. Use of ShrinkResources
The ShrinkResources method will be displayed in the build. Gradle file. This method will remove the resources which are not being used in the project.
You have to enable it by specifying it to be true. You can find this method in build.Gradle file > buildTypes > release > shrinkResources. Enable it to true.
7. Limit the usage of external libraries
These external libraries will install the classes provided by them, some classes are not required, so they can consume storage and will lead to an increase in APK size. So it is preferable to limit the usage of external libraries to reduce APK size.
8. Reuse your code
try to use the available design pattern because Repetitive code will increase the size of that particular file, and it will lead to an increase in APK size.
9. Use of R8 to reduce the size of APK
R8 works similar to that of proguard. R8 shrinking is the process in which we reduce the amount of code, which helps to reduce APK size automatically. R8 works with proguard rules and shrinks code faster, improvising the output size.R8 is already present in your application you just have to enable it.
R8 is faster than proguard as there are fewer number of steps. It reduces the size of the app in an optimized manner.
10. Reduce library size
you can also double-check the external libs and try to use official libraries provided by Google.
Remove any debug library you have in the app. It can be done by using debugImplementation while building testing debug apk.