EASY HACKS FOR REDUCING APP SIZE BY 60% (IN APPROXIMATELY 5 MINUTES)

The size of the app really matters when putting the Play Store online. Many mobile app development companies in Dubai believe that there are myriad ways to reduce Android APK app size. Nonetheless, I’ll start to channel one of the more effective approaches I’ve used to reduce app size.
But, before we move on to the quick fixes to reduce app size, let’s familiarize ourselves with the need to reduce app size.
As everyone already knows, mobile devices have limited resources. They have a set amount of battery, confined storage, limited processing power, limited RAM, limited internet connectivity and the list goes on. However, it doesn’t matter if you are targeting Android or even iOS app development. This is the universal truth.
To better understand, let’s take an example of an Android application “Anti-Theft Screen Lock”. This app takes images using the device’s front camera, broadcasts an alert notification whenever someone tries to violate a mobile password to access the device.
Here I am deploying the easy and effective tweaks and tips I applied to keep the app size to a minimum. These tips and tricks will surely help you to solve your queries for current and potential applications in order to give the right start for launching your application in the market.
IS THE SMALLEST ALWAYS BETTER?
As an Android app developer we always care about app performance, design and user experience are essential. But, most developers forget (or minimize) one thing: “app size”. This is one of the deciding factors if you want to target the next billion users of your app.
To your surprise, more than 11,000 Android devices are available in the market and most of them have the pocket-sized and low-end configuration, limited storage capacity (1 GB to 8 GB of internal storage) as well as 2G and 3G connectivity. Undeniably, these devices take the lion’s share in many countries, where it’s easy to find your next billion users.
Thus, keeping the size of the application intact and optimal is the new constant of the application development company par excellence. The less user storage of your application, the more space the user has to store their information and data such as images, videos and files.
So, to be fair and square, you don’t want your user to install your app just because of the “Insufficient storage space” notification.
Some countries also have constraints regarding limited 2G / 3G connectivity. So if your app is large, it will take longer for the app to download (and there is a higher chance that users won’t download it in the first place). Also, most users have a limited data limit. Every byte the user uses to download the app is sure to affect the user’s pocket.
So, it’s clear that in the world of mobile apps, smaller is always better.
So, let’s get started right away with adjustments and tips for “How to reduce the size of your Android app”.
Visit Also: Android App Development Company in Dubai
The list skyrockets like this:
PROGUARD
This is used for code reduction.
There are many code wrapping tools like Proguard that can significantly eliminate or minimize code clutter. Once you have started implementing proguard on the written code, you should test the application thoroughly when it exchanges symbols. You can read more about this optimal tool on Google by searching proguard from sourceforge.
APK DIVISIONS
The Split mechanism makes it possible to create apps for certain forms of Multi-APKs more efficiently than using flavors. This approach allows you to develop APK for specific density and ABIs.
VECTOR DRAWABLES
With the launch of Support Library 23.2, Android strengthens vector design for older versions of Android devices. Android studio offers a way to simply convert SVG to vector drawing. Here, we don’t have to worry about the different DPI devices. This approach will significantly reduce the size of the application.
GOOGLE PLAY SERVICES
Choose exclusively the compilation APIs.
In versions of Google Play services earlier than version 6.5, you had to compile the full API package in your app. In some scenarios, this made it more tedious to keep the number of methods in your application (including framework APIs, its own code, and library methods) under the limit of 65,536.
From version 6.5, you can quite selectively compile the Google Play service APIs in your own application. For example, to contain only the Google fit and Android wear APIs, replace the following line in your build.gradle file:
“Compile” com.google.android.gms: play-services: 8.4.0 “:”
with these lines:
“Compile” com.google.android.gms: play-services-gcm: 8.4.0 “”
“compiles” com.google.android.gms: play-services-wearable: 8.4.0 “”
Read Also: Ecommerce Growth Hacks for Ecommerce Startups
REMOVE UNUSED RESOURCES
Knowledgeable application developers in Dubai use android-resource-remover utility which removes unused resources reported by Android Lint from your project.
OPTIMIZE PNG IMAGE
PNG images can be reduced to a minimum file size without losing quality. To do this, it is advisable to use a tool such as OptiPNG and PNGCrush. They are both great for reducing the size of the PNG file while keeping the image quality intact.
IMAGES OF 9 PATCHES
A 9patch png is a special format for PNG images that can be used for backgrounds. Nine patch images turn out to be special when designing buttons. Rather than setting a normal bitmap to use as the background, a 9patch defines nine segments – for each of the four corners, the four edges, and the center.
Even try to minimize JPEG files as much as possible. For better use, you can use tools such as Paint.NET.
REMOVABLE DEBUG INFORMATION
All the debug related information should be excluded, which is a considerable aspect to reduce the size of the Android APK. The application technically does not read or use this data, and the Android operating system can run the respective application seamlessly without this information.
However, to keep in mind is that the debug information only acquires more space, and should be deleted.
GIVE THE SLIP TO DUPLICACY
You need to make sure that the app does not have duplicate modules or replicate any assets is a very common way to eliminate the retention of junk files in your APK. The most important way is to understand which Android APIs you can integrate and the full set of features that each provide. A single API can serve the purpose of many other APis and we need to make sure to determine which one is the most efficient.
Duplicate items (strings, bitmaps, etc.) also gain a lot of space and can be easily removed. To a lesser extent, the cloned code will also unnecessarily increase the size of the final delivered product i.e. the binary.
Visit Also: UI UX Development Company in Dubai
EXCLUSIVE USE OF PLUSH
Proguard works on the Java side. Unfortunately, that doesn’t work on the resource side. As a result, if a my_image in res / drawable is not used, Proguard only removes its reference in the R class but keeps the associated image in place.
Lint is a static code analyzer that provides you with functionality to detect all unused resources with a simple call to ./gradlew Lint. It produces an HTML report and gives you the exhaustive list of resources appearing in the “UnusedResources: Unused resources” section. You can safely delete these resources as long as you do not access them through your code reflection.
To be precise, Lint scans the resources (i.e. files under the / res directory) but ignores the assets (i.e. files under the / assets directory). While resources are accessible by name rather than a Java or XML reference, therefore, Lint cannot determine whether or not a resource is used in the project. It is up to the professional to keep the folder / asset clean and free from unused files.
REUSE RESOURCES EVERY TIME POSSIBLE
Reusing items or resources is one of the first critical optimizations you learn when you start building on mobile. In a list view or a RecyclerView, reuse helps you keep the pace of scrolling performance smooth.
But reuse can also help you minimize the final size of your APK. for example; Android offers many utilities to recolor an asset either with the new Android: tint and Android: tintMode on Android L, or with the old one which adapts to all ColorFilter on all versions.
You can prevent the packaging of resources that are only a rotating equivalent of other resources. Suppose you have two you had to compile the full API package in your app. In some scenarios, this made it more tedious to keep the number of methods in your application (including framework APIs, its own code, and library methods) under the limit of 65,536.
From version 6.5, you can quite selectively compile the Google Play service APIs in your own application. For example, to contain only the Google fit and Android wear APIs, replace the following line in your build.gradle file:
“Compile” com.google.android.gms: play-services: 8.4.0 “:”
with these lines:
“Compile” com.google.android.gms: play-services-gcm: 8.4.0 “”
“compiles” com.google.android.gms: play-services-wearable: 8.4.0 “”
REMOVE UNUSED RESOURCES
Knowledgeable application developers in Dubai use android-resource-remover utility which removes unused resources reported by Android Lint from your project.
OPTIMIZE PNG IMAGE
PNG images can be reduced to a minimum file size without losing quality. To do this, it is advisable to use a tool such as OptiPNG and PNGCrush. They are both great for reducing the size of the PNG file while keeping the image quality intact.
IMAGES OF 9 PATCHES
A 9patch png is a special format for PNG images that can be used for backgrounds. Nine patch images turn out to be special when designing buttons. Rather than setting a normal bitmap to use as the background, a 9patch defines nine segments – for each of the four corners, the four edges, and the center.
Even try to minimize JPEG files as much as possible. For better use, you can use tools such as Paint.NET.
REMOVABLE DEBUG INFORMATION
All the debug related information should be excluded, which is a considerable aspect to reduce the size of the Android APK. The application technically does not read or use this data, and the Android operating system can run the respective application seamlessly without this information.
However, to keep in mind is that the debug information only acquires more space, and should be deleted.
GIVE THE SLIP TO DUPLICACY
You need to make sure that the app does not have duplicate modules or replicate any assets is a very common way to eliminate the retention of junk files in your APK. The most important way is to understand which Android APIs you can integrate and the full set of features that each provide. A single API can serve the purpose of many other APis and we need to make sure to determine which one is the most efficient.
Duplicate items (strings, bitmaps, etc.) also gain a lot of space and can be easily removed. To a lesser extent, the cloned code will also unnecessarily increase the size of the final delivered product i.e. the binary.
EXCLUSIVE USE OF PLUSH
Proguard works on the Java side. Unfortunately, that doesn’t work on the resource side. As a result, if a my_image in res / drawable is not used, Proguard only removes its reference in the R class but keeps the associated image in place.
Lint is a static code analyzer that provides you with functionality to detect all unused resources with a simple call to ./gradlew Lint. It produces an HTML report and gives you the exhaustive list of resources appearing in the “UnusedResources: Unused resources” section. You can safely delete these resources as long as you do not access them through your code reflection.
To be precise, Lint scans the resources (i.e. files under the / res directory) but ignores the assets (i.e. files under the / assets directory). While resources are accessible by name rather than a Java or XML reference, therefore, Lint cannot determine whether or not a resource is used in the project. It is up to the professional to keep the folder / asset clean and free from unused files.
REUSE RESOURCES EVERY TIME POSSIBLE
Reusing items or resources is one of the first critical optimizations you learn when you start building on mobile. In a list view or a RecyclerView, reuse helps you keep the pace of scrolling performance smooth.
But reuse can also help you minimize the final size of your APK. for example; Android offers many utilities to recolor an asset either with the new Android: tint and Android: tintMode on Android L, or with the old one which adapts to all ColorFilter on all versions.
You can prevent the packaging of resources that are only a rotating equivalent of other resources. Suppose you have two images named ic_arrow expand and ic_arrow_collapse:
You can quickly get rid of ic_arrow_collapse by creating a RotateDrawable using ic_arrow_expand. This technique also reduces the time your designers need to manage and export the reduced asset variant.
RECOMMENDATIONS FOR THE MEDIA FORMAT
If your app only depends on heavy images, audio and video, you can also reduce the APK size of your Android app by using specific media formats. I personally recommend that you use the formats listed below for the respective media needs such as images, audio, and video:
Images: PNG or JPEG. Go for PNG, although it is a lossless format, but it is great for textures and illustrations as there will be no visual artifacts from compression. In addition, if there are space constraints, the Android app developer uses JPEG or an amalgamation of PNG. a high quality JPEG image may work well for large photorealistic images, for which the JPEG compression scheme is optimized.
Video: better to go for H264 AVC. encode the video to a specific resolution that is not larger than the target device’s screen.
Audio: The first choice for the audio resource is AAC. AAC performs better compression at a given quality, compared to MP3 or Ogg Vorbis. Raw formats such as WAV should never be used. The common rationale for using the WAV format is that decoding compressed audio streams usually means higher playback latency.
Still, Android offers the Sound Pool API, which allows apps to use compressed audio streams without the cost of high latency.
In The End
At present, there are a lot of requirements for Android apps in the market, resulting in the development of reliable Android apps. However, the biggest problem for developers is to reduce the size of the APK as well, without affecting the performance of the application.
So, to make this trip a flawless one, Napollo is here to help.
Their experts consider this scenario and thus provide you with easy tweaks and tips which turns out to be a boon for successfully launching your project with utmost ease by minimizing APK size.