How to Reduce App Size from 50 Mb to 5 Mb in Just 3 Steps?

app size reduce

If you are a developer and thinking that you are being paid for developing an app, you are brutally wrong. Like a pilot flies the aircraft through the shortest and fastest distance to save the fuel for an airline company, you need to fly through some techniques of developing an app which is sized as minimum as possible to save the app going to have a crash landing in the market.

If you have noticed closely, all major companies like Uber and Facebook have launched the ‘lite’ version of their native apps. These lite apps of Uber and Facebook are sized 60-70% lesser than their native apps. These lite apps consume fewer data and run smoothly even on old phones which aren’t equipped with next-gen processors.

The reason why mobile app development companies put emphasis on the app size is the fact that in many countries of Latin America and Asia which hold so much potential for such apps, the network bandwidth and smartphone configuration aren’t satisfying the basic requirements to run size-heavy apps and as a result, many companies cannot reach to their desired installation rate.

By concluding last three paragraphs, it is totally safe to say that the success rate of the app highly depends on the app size and so, it becomes the need for developers to have knowledge about different ways to reduce the app size by 50% to 60%.

In this blog, I will share a few techniques to reduce the app size along with tutorials. But to do it, it is very crucial that you satisfy a very fundamental pre-requirement.

Pre-requirement

Before you go for reducing app size, there is a pre-requirement which says that you need to analyze the app. To analyze the app, you can use Google’s very handy tool, APK analyzer. With this tool, you can tear down the app and know the files which are taking the larger amount of space.

As a tip, Google has integrated APK analyzer tool into the Android Studio itself. By selecting Analyze APK from the Build menu bar or by dragging the APK into the Editor window of Android Studio, you can start analyzing your app.

After completion of the analyzing process, you get the result similar to the following picture.

Here as you can see, Classes.dex, res, and resources.arsc utilize most of the space. The classes.dex file includes Java code’s byte code files. Res contains images, menu files, layout, and icons. Whereas, resources.arsc file holds the styles, string, dimensions, integers, etc.

So, if you reduce the size of these three major components of API, you can easily achieve a light app. And guess what? I will discuss the same in the next section of the blog. I will present a few techniques to reduce the size of text, images, libraries, and other resources which will eventually reduce the overall size of the app.

1) Reduce class.dex by removing unneeded resources including classes and code

As discussed earlier, the class.dex file holds the java code which means, gradle intermixes all .class file and converts it to a .dex file which is later stored in class.dex file.

Here it is worth to mention that a class.dex file can store up to the 64K methods. So, if your app has more methods than 64k, you need to create another class.dex file.

In order to reduce the class.dex file size, a free java class named Proguard is very useful. It detects and removes those classes and methods which aren’t useful and eating unnecessary space.

To enable the proguard and reduce the class.dex size, you just need to write a straightforward code, like following.

buildTypes { Release { shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile (‘proguard-android.txt’) , ‘proguard-rules.pro’ } }

2) Reduce the size of res

After class.dex, the another largest component in your APK is res that contains images, XML and raw files. However, you cannot reduce the size of XML like images as XML includes the layout of the app.

There are several methods you can opt to reduce the size of the images. But we are going to discuss very few efficient and useful methods.

  • Instead of adding an image of any shape, use drawable resources of the Android Studio. This drawable resources can be drawn to screen by writing a few lines of code.
  • But sometimes, when drawable resources don’t fit perfectly to your requirement and the only option you have is to use an image, make sure the format of the image is .webp. The size of the image having .webp format is considerably very low than the image with .jpg and .png format.

As you can see from the following image, the quality of both images is equal, but the size of the image with .webp format is 31% lower than an image with .jpeg file format.

  • Going a mile further, if you still think that the .webp image size is high, you can go for vector images which are very light.

3) Reduce resources. arsc

To reduce the size of resources.arsc, there are several methods.

  • Automatically generated codes need to be deleted.
  • Avoid ENUM because the value of ENUM is the object and every declaration takes some memory. You can take @IntDef annotation and ProGaurd into account to avoid ENUM. Following code shows the way of using @intDef into APK.
  • Size of native binaries should also be reduced. To do that, there are two ways. First is all about removing debug symbols with the help of arm-eabi-strip tool and second is all about avoiding extracting native libraries by employing android:extractNativeLibs = “False”.

So, if you somehow achieve what we have just discussed, you can easily develop a feature-packed app which is sized only 5MB. Developers from all around the world, use these only methods to reduce the size of the mobile app. In fact, at my IT company, we have delivered 200+ mobile apps which are sized under 10MB, and do you know?, the secret recipe we are using is what I have just discussed with you.

How to Reduce App Size from 50 Mb to 5 Mb in Just 3 Steps?
Scroll to top