Boost your app downloads by shrinking your app size

1516896449 boost your app downloads by shrinking your app size

Since the Android Marketplace introduced in March 2012, moderate app size has quintupled. Some of this build up is sensible. Today, we predict richer content material, higher graphics, and extra options from our cellular apps, and none of this comes without cost! The reminiscence to be had on your standard Android gadget has higher, so why shouldn’t apps employ this additional area if it is helping them ship a greater person revel in?

If your app goes to achieve as many customers as imaginable, you want to be aware of the size of your Android Package Kit (APK). A up to date learn about revealed by a Strategy and Operations Analyst at Google confirmed APK size without delay impacts the quantity of people that finally end up putting in your utility after visiting its retailer web page. According to those findings, for each and every 6 MB build up within the size of your APK, you’ll be able to be expecting to look a 1 % lower within the set up conversion price.

There are many the reason why the size of your APK may well be protecting your utility again:

  • The person notices the APK size on your app’s Google Play record, and comes to a decision to not set up it in keeping with this knowledge.
  • The person is drawing near their knowledge prohibit and doesn’t need to incur further prices.
  • The set up fails because of a loss of area at the goal gadget. This is an issue specifically in markets the place price range units are extra not unusual, similar to rising markets.
  • The set up fails because of community connectivity problems, which can be much more likely to happen all over long downloads.

In this newsletter, I’m going to turn you ways to verify folks visiting your app’s Google Play web page in reality finally end up putting in it by sharing equipment, tactics, and new options to assist create a miles leaner APK.

Remove unused strategies and categories with ProGuard

ProGuard is a device which is able to establish and take away unused categories, fields, strategies, and attributes from your utility code and any libraries you will be the usage of.

For the most productive outcome use the proguard-android-optimize.txt report, which has the similar settings because the default proguard-android.txt report, however with optimizations that carry out research inside of and throughout strategies.

Here’s how one can allow ProGuard in your challenge’s module-level construct.gradle report:


Every time you construct your challenge, ProGuard will generate a app/construct/outputs/mapping/liberate/utilization.txt report that lists the whole thing ProGuard has got rid of from your APK, so take a look at it to verify it hasn’t stripped away any code your challenge in reality wishes.

If ProGuard does take away vital code, then open the construct/intermediates/proguard-files/ report and use the -keep flag to specify the code that you wish to have to hold onto:

-keep public elegance MyActivity

Since ProGuard might take away code that your challenge does in reality require, you must at all times check your challenge with ProGuard enabled, prior to publishing your ultimate APK.

Remove all unreferenced assets

Sometimes unused assets can in finding their manner into your challenge, specifically in the event you’re the usage of libraries. Since unreferenced assets are simply taking on useless area, you must inform Gradle to seek for, and take away those assets by enabling useful resource shrinking:


Whenever you construct your challenge, the Gradle Console will supply an outline of what number of assets it’s controlled to take away, however you’ll be able to view an inventory of those assets in your challenge’s app/construct/outputs/mapping/liberate/assets.txt report.

While useful resource shrinking can assist scale back the size of your APK, it has its barriers. It can’t take away assets from the “values” folder, and it gained’t take away useless choice assets.

For each and every 6MB build up within the size of your APK, you’ll be able to be expecting to look a 1% lower within the set up conversion price.

You must use useful resource shrinking together with Lint, a static scanning device which is able to establish assets that aren’t referenced in your code.s

To run Lint, make a selection Analyze — Inspect Code… from the Android Studio toolbar. If Lint detects any unused assets, then it’ll show the next message in a brand new Inspection Results window: “Unused assets — The useful resource R.drawable.ic_launcher_background2 seems to be unused.”

Lint can simplest hit upon unused assets, so that you’ll nonetheless want to take away them manually.

Compress your drawables

Graphical belongings are steadily the most important contributor to APK size, so compressing your drawables can considerably scale back the size. If you’re operating with JPEGs, you’ll be able to take a look at a compression device similar to packJPG. If your challenge comprises PNGs you’ll be able to use zopflipng, pngcrush, OptiPNG, TinyPNG or pngquant.

The Android Asset Packaging Tool (AAPT) optimizes the contents of your res/drawable folder mechanically. If you compress your PNGs prior to passing them to AAPT, then it will in reality finally end up inflating your PNGs.

If you compress your PNGs manually, remember to disable the AAPT procedure for them like this:

android {

Switch to WebP

If your challenge’s minSdkVersion is 18 or upper, changing a PNG, JPEG or BMP to WebP structure steadily supplies higher compression, in addition to the similar symbol high quality.

  • In Android Studio, control-click the picture you wish to have to transform, or a folder containing a couple of pictures.
  • Select Convert to WebP…
  • In the following menu, choose from lossy or lossless encoding.
  • Check the Skip pictures when the encoded result’s better than the unique field.
  • Click OK to accomplish the conversion.

If you turn to WebP, you’ll nonetheless want to supply your launcher icon as a PNG.

Modify pictures at runtime

If you want to make use of diversifications of the similar symbol, attempt to provide a unmarried “base” symbol that you simply customise at runtime anywhere imaginable. You can practice a tint to a picture the usage of setTint() and rotate drawables the usage of attributes like android:fromDegrees and android:pivotY.

Use vector graphics

On Android and better, you’ll be able to draw belongings at runtime by defining a VectorDrawable, which is an XML illustration of a vector. These XML information comprise trail instructions telling Android how to attract the strains and arcs that make up this graphic.

Unlike many symbol codecs, vectors can scale with out shedding definition, so that you simplest want to supply one asset according to symbol. However, rendering VectorDrawable gadgets is an in depth procedure, and also you must simplest use them for small, easy graphics.

Always do your analysis

On Android and better, you’ll be able to draw belongings at runtime by defining a VectorDrawable, which is an XML illustration of a vector.

Before including any library to your challenge, you must take a look at its code size so you already know precisely what affect it’s going to have on your ultimate APK. You must additionally glance seriously on the options this library supplies, as it will comprise an important quantity of code, in addition to assets your challenge doesn’t in reality want. For best possible effects, at all times select a library that’s compact, optimized for cellular, and comprises simplest the options that you simply’re in reality going to make use of.

There’s no scarcity of third-party libraries available in the market, so it’s at all times price buying groceries round to search out the smallest library that also meets your wishes.

Remove unused library code

Libraries might comprise strings for a variety of languages, however in the event you challenge doesn’t explicitly give a boost to those languages then those strings are simply including useless bulk to your ultimate APK.

Open your construct.gradle report and specify the languages that your utility formally helps, then Gradle will mechanically exclude all assets for languages  your utility doesn’t give a boost to, together with strings from 0.33 celebration libraries:

android {
defaultConfig {

//Use resConfigs to specify the languages that your app formally helps//

   resConfigs "en"

Get particular with Google Play Services

Many tasks use Google Play Services. Rather than including all of the library to your challenge, you must simplest come with the APIs you’re in reality going to make use of. If you simplest require get entry to to the Google Location APIs, then simply use this:

implementation ''

Rather than this:

implementation ''

Consider growing a couple of APKs

It’s lovely same old follow to put up a unmarried APK containing trade assets for various gadget configurations. Occasionally this technique might require customers to obtain numerous belongings they’ll by no means use. If your APK is full of high-density graphics, you’re necessarily asking customers on low-density displays to waste treasured space for storing on pictures their gadget bodily can’t show.

In this state of affairs, you could need to believe setting apart your unmarried APK into a couple of APKs which comprise simplest the code and assets required for particular display screen densities or Application Binary Interfaces (ABIs). When the person downloads your app from Google Play, they’ll obtain an APK containing simply the assets to focus on their specific gadget.

To generate APKs in keeping with display screen density, upload the next to your construct.gradle report:

android {

//Create a ‘splits’ block//

splits {

//Create a ‘density’ block//

    density {

      allow true

//Generate separate APKs for the next display screen densities//

come with "ldpi", "mdpi"

Even in the event you generate a couple of APKs for particular display screen densities, Gradle will at all times generate an APK containing the belongings for all display screen densities, so remember to put up this common APK to supply a fallback for units that don’t fit any of your density-specific APKs.

Different Android units use other CPUs, which in flip give a boost to other instruction units. Each aggregate of CPU and instruction set has an ABI, which defines how the appliance’s gadget code interacts with the gadget.

Gradle bundles the binaries for all ABIs right into a unmarried APK by default, however you’ll be able to additionally create APKs in keeping with ABI. When you inform Gradle to generate ABI-specific APKs, it gained’t mechanically generate a common APK, so that you’ll want to come with particular directions to create this common APK:


Google Play is not going to assist you to add a couple of APKs to the similar record, if the ones APKs have the similar model knowledge. If you create a couple of APKs, you’ll want to assign every APK its personal modelCode worth.

Allow your app to be put in on exterior garage

Some customers might select to increase their gadget’s integrated reminiscence by including exterior garage (maximum frequently an SD card). Unless you request in a different way, Android will save you the gadget from putting in your app on exterior garage, so set up will fail if there isn’t good enough on-device garage, regardless that a number of exterior garage is to be had.

To give Android the choice of putting in your app on exterior garage, open your challenge’s Manifest, and upload both of the next strains:

  • android:set upLocation=”preferExternal.” Your app prefers to be saved externally, however may also be put in on inner garage.
  • android:set upLocation=”auto.” Your app will also be put in on inner or exterior garage, however the gadget will set up your app on inner garage by default.

Even if your APK is put in on exterior garage, all personal person knowledge, databases, optimized .dex information, and extracted local code will nonetheless be stored to inner reminiscence.

Consider providing your challenge as an Instant App

For customers who’re suffering with space for storing, connectivity problems or restrictive knowledge plans, rapid apps is also the one viable manner of experiencing what your utility has to supply.

If you practice all of the above tactics and best possible practices, you must be capable of considerably scale back the size of your APK. No topic how slender your APK, the method of downloading and putting in an app will at all times be the most important barrier between your utility and doable new customers.

So why now not give customers a strategy to revel in your utility with out putting in your APK?

Android’s “Instant Apps” function permits you to separate your app’s maximum necessary capability into stand-alone modules, and map every of those modules to a URL. The person can then load a module on call for by clicking its URL, which makes your app straight away obtainable from any location that helps URLs, like emails, Google seek effects, boards, and YouTube feedback.

Behind the scenes, Instant Apps are delivered by means of a light-weight Instant Apps APK which comprises simplest the code and assets required to ship this actual function, and at all times is available in at 4MB or underneath.

For customers suffering with space for storing, connectivity problems, or restrictive knowledge plans, rapid apps is also the one viable manner of experiencing what your utility has to supply. Hopefully, their revel in with your Instant App will encourage them to put in your complete APK additional down the road, after they’re ready.

Wrapping up

To be certain customers aren’t get rid of by the size of your app or aren’t ready to put in it as it takes up an excessive amount of of the interior garage, it is very important scale back the size of your ultimate APK report.  The tactics above may just convey some dramatic financial savings which with a bit of luck will convert without delay into downloads and a more fit put in base.

Do you could have any further pointers for slimming down your Android apps? Let us know within the feedback under!

Leave a Reply

Your email address will not be published. Required fields are marked *