Please choose code language:
How to Reduce Your Android App Size
This topic is assigned to Ghenadies
JustAlex 2019 May 02 13:11

“New smartphone and tablet launched with unlimited memory and unlimited battery life!”

Imagine waking up to this news and being tempted to get hold of such a dream gadget. Every smart device user feels the space crunch at some stage, irrespective of the memory storage capacity of his or her device. A major reason for this is the number of photos, videos and apps that smartphone users tend to download or save on their devices. And, as a mobile app developer, you can help your users save some space on their phones or tablets by designing lightweight mobile apps.

The app market is huge with around 85% of the time spent on smartphones being spent on apps, according to a 2015 survey done by Nielsen. However, on average, a mobile user has around 26 to 27 apps on his or her device, which makes it really tough for your app to be among those most used.

So, reducing the size of your mobile app gives it a good chance of being preferred by users and will go a long way in ensuring that it is not the first app to be deleted when the users face any shortage of storage space.

In this article, we look at some useful ways and tricks to reduce the size of your Android (APK) app and provide insight into app thinning methods.

How to Keep an Android App’s Size Down

Use the Command Line Tool Proguard

You can use free tools like Proguard, available at Sourceforge, to shrink the APK file size. It serves as a free Java file shrinker, obfuscator, and optimizer that identifies and gets rid of unused fields, classes, methods, attributes, and more. Proguard also offers protection against reverse engineering and tampering and helps with code optimization.

Use Recommended Media Formats

You should prefer the following formats for different media files:

  • Audio – AAC
  • Video – H264 AVC
  • Image – PNG or JPEG

Get Rid of Debug Information and Symbols

You need to remove any information that your users do not need and that occupies space on your app. Debugging statements like Log.i(), qualifies as such useless information and you need to get rid of it after successfully testing your app.

Also, once the app has gone live, remove all the debug symbols (from the native libraries) that you may have used during development.

Do Away with Unused Resources
You can remove unused resources from the APK during the build process by using the Android gradle plugin that possesses the “shrinkResources” gradle property. This activity can help to potentially reduce the app’s size by almost 0.5MB. You can activate this functionality by adding the “shrinkResources true” code to your release configuration as indicated below:
Build.gradle

Build.gradle

android {

buildTypes{

release{

shrinkResources true

minifyEnabled true

}

}

}
Compress PNG and JPEG files

Generally, PNG images are of very high quality which results in bigger file sizes for your app. So, you need to compress and optimize such PNG files, without loosing the quality by using tools like PNGCrush, TinyPNG, and OptiPNG.

If you need to use JPEG images, then compress them as much as possible through free tools like Paint.NET.

Prevent Duplication

Avoid duplication by making sure that every file in your APK offers a unique functionality, i.e., two files should not provide the same functionality. Also, get rid of any duplicate assets in the form of bitmaps, strings, and so on to save space on your Android app.

Choose the .svg Format System App Icon Set

The next time you download a system app icon set from Google’s Material Icon Library, use the .svg format instead of .pngs to enjoy a lighter app. This is now possible with the introduction of Support Library 23.2. Moreover, this trick takes care of the necessary device DPIs.

We hope that the above tips for reducing your Android app’s size proves useful to you. Remember, the reduced size will not only make it convenient for your Android users to download and update your app on the go, it will also ensure that your app is not the first on their hit list when they are on the lookout for heavyweight apps that can be deleted to create memory space. Also, the size of your Android app could literally be one of the all-important parameters that determines its success.

You must login to post messages. Click here to log in.