Top Tricks to Reduce Android App Size
Before starting the write-up, I would like to ask a question! Do you know around 70% of folks in the rising market consider an app’s size prior to downloading it since they are anxious about their phone storage space and data cost?
How to Reduce Android App Size?
It makes sense why you are here! Yes, users quite often avoid installing mobile apps that appear too large, particularly today when devices work on pay-by-the-byte plans or linked to often-spotty 3G and 4G networks.
A Quick Trick!
If I talk about the most uncomplicated approach to gain instant app size savings, while publishing it to Google Play, then it is uploading the mobile application as an Android App Bundle. It is a fresh upload format, including all code and resources of your app, but log in to Google Play & put off APK generation.
The new app serving type of Google Play, known as Dynamic Delivery, then utilizes your app bundle for generating and serving optimized APKs for individual’s device configuration.
Consequently, they download the code and resources they require to run the app. There is no need to develop, sign, and handle various APKs to support multiple devices, and users get slighter, more optimized downloads.
Since Google Play imposes a compressed download size limitation of equal or less than 150 MB for applications deployed with app bundles, you can even apply the guidelines mentioned on this to reduce the download size of your app as much as feasible.
You must be thinking that this trick is going to help at the time of deployment, but what if we want to get it done during the app development process? Is there any technique for that?
The answer is YES. Let’s find out the reason behind the app’s large size, and then, we will discuss some critical hacks to reduce the size of your Android App during its development lifecycle.
Why Do Large Apps Exist?
Building a mobile app with extra features is like icing on the cake. However, modern-day mobile apps have been puffed up due to three key reasons:
- Enhancing UX expectations
- Extremely mounting feature sets
- Compatibility for a broad range of screen densities and sizes
Here Are the Perfect Solutions:
It is possible to reduce the size of an image without tempering the resolution or pixel. For examples, you can convert .png and .jpg image to .webp web image to reduce the app’s size without compromising with its quality or class. The .webp provides transparency like .png and irreversible compression as .jpg.
Now, if you are thinking how to convert it, then there are various tools for the same, such as, for .jpg file conversion, guetzli and packjpg whereas for .png files zopflipng and pngcrush. Designers can even execute vector graphics for building an easy resolution that doesn’t cheat for space.
It is evident; a few images can perform without static assets. You can use the framework to sketch such images with dynamism.
No doubt, making use of Vector Drawables items is an excellent thought when tiny apps are to be built. They can sustain on nominal space in the APK file. Also, they can create images compliant as directed by material design.
An additional technique is to utilize the aapt utility to crunch or compress .png images. For example, a true-color image (in .png format) can be transformed into a color palette.
But, app developers must keep in mind that the aapt utility wouldn’t crunch .png files in the folder or asset. Moreover, it is not going to optimize images with over 256 colors and may puff up your .png file which has been shrunk.
Eliminate Unnecessary Class & Resources
Lint, a static code scrutinizer and an element of Android Studio, can check resources in a folder or res not mentioned in code.
This indicates the needlessness of resources, and when the tool figures out such resources, it displays this notification:
For example, at the time you insert libraries into the code, unnecessary resources may follow. Lint will verify the resource and send you the message. But, developers must know that the utility will not scan the assets or folder by means of reflection.
In order to eliminate the unused resources automatically, you can opt for the Gradle tool. Just facilitate code shrinking to utilize shrinkResources & let it in the mobile app’s build.gradle file.
In the process, a tool known as ProGuard, which is a Java class file obfuscator, preverifier, shrinker, and optimizer with competence to recognize and eliminate idle resources, attributes, fields, methods, and classes or rephrase these with short names, holding no sense.
It can eradicate all inactive techniques and cut the classes.dex file after you put minifyEnabled to true.
Reduce Resources Usage from Libraries
External libraries are helpful to build Android apps and make them wholly versatile and usable. Those, which are common, are Google Play Services that are utilized to recover automatic translations of applications text, as well as Android Support.
But, such kinds of libraries are even developed for desktops or servers and come with multiple approaches that don’t provide the mobile app any motive. Nonetheless, you may modify the files & preserve those sections needed by your app.
Enums are complicated, and a single can insert from 1.0-1.4 KB to an app’s file classes.dex. These can build up at ninja pace, mainly if there are common libraries or multifaceted systems.
Therefore, it’s suitable to push clear of details. How? With the help of @IntDef annotation and ProGuard to exchange details into integers.
Today, we look forward to better graphics, richer content, and additional features from mobile apps, and we all know, none of these comes for free! It is evident that the memory on your Android device has amplified, so why shouldn’t mobile apps use this extra space if it aids them to deliver an excellent user experience?
On the other hand, it is also the fact that applications with huge size come up their own set of cons.
Considering all this, I have discussed some proven solutions for Android developers who want to reduce the size of an app during its development process. Hope, the write-up will help you out!