How I reduced my App Size: Android App Bundles

Drithi Shetty
Tata CLiQ Technology
5 min readMar 2, 2022

The title may be inspired by “How I met your mother” but this blog is about a metric we all should be passionate about.

Keeping your customers hooked on your app could be one of the most important aspects for any app developer. To achieve this for our Tata CLiQ app we added some cool features like virtual try-on, chat, subtle animations, and many more but everything comes at a cost! We had to add many libraries & SDKs to support all of that and yes, these libraries bloated our app size.

Source: Me, myself & I :)

A small APK size can lead to more customers and also a better first impression of the app or let me say it this way…it can drop your user acquisition numbers dramatically.

We tried different ways of shedding this additional weight (size 😉) — code optimizations, getting rid of some libraries, whatnot. But the gain was merely 2–5 MBs 😒. We followed many best practices and lean tactics to hit our targeted size but the hero of our story is — App Bundles. Guess what, we reduced our app download size by a whopping 35%. Phew!!

Don’t believe me? Let me tell you how.

So what’s an Android App Bundle? — It is a publishing file format for Android applications, whereas an APK is the packaging format that will be installed on a device.

Google uses app bundles to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app.

Why should I use this?

How many times have you downloaded a big application? Rarely, right?

Without writing any extra code or using tools, the app bundle helps to reduce the size of apps. Thus, users can get smaller and more optimized downloads.

Additionally, Here’s why you may want to switch to this today.

Release apps faster by avoiding strenuous multi-APK releases as Google Play will handle the targeting for you, based on the user’s device configuration.

You’ll get more reporting and optimization help in the Play Console, which is only available with app bundles that are published.

Dynamic Delivery also allows us to modularize app features. Suppose we want an AR feature that isn’t required at the time of installation, we can add this as a dynamic feature module in the app project and include them in the app bundle. Users can then download and install your app’s dynamic features on-demand.

If you want your users to update the app to your latest version without leaving the app, you can take advantage of Play Core Library’s in-app updates.

As a meme lover, found this apt! :) [unknown source]

How does it work?

You may have heard of Dynamic delivery by now. It serves only those files to the users which they need and this is what allows us to make apps smaller.

How does it generate the APK from the app bundle?

App bundle contains three kinds of split APKs:

  • Base APK: APK contains the common resources & code.
  • Configuration APKs: contain native libraries and resources for a specific screen density, architecture, & language.
  • Dynamic feature APKs APKs that contains resources that are not required when your app is first installed but may be downloaded later.

Your app bundle has the base and config APKs. Suppose, a user tries to install the application from Google Playstore, the Playstore serves only the subset of these APKs. For example, A user has a Samsung device with configurations: x86, xxhdpi, en language, the final APK will be a combination of configs: (base+x86+xxhdpi+en).apk.

If the user moves to another country and adds or changes the language in the device settings, Playstore detects this and attempts to download the new additional language split (APK) for all apps that use the dynamic delivery concept on the device. If the internet is not available then it will download the configurations later.

Devices running Lollipop and higher get the most optimized APKs from dynamic delivery. The older devices get the APK from the app bundle generated by Goole Play.

For more information check out the android developer's official website.

How do we implement this?

  1. Play App Signing

To enroll your app bundle on the Play console you will need to have a play app signing.

Google manages and protects your app’s signing key and uses it to sign optimized, distribute APKs that are generated from your app bundles. Play App Signing stores your app signing key on Google’s secure infrastructure and offers increased security with upgrades.

To know how to set it up and know more about it, visit this!

2. Generate an App Bundle

App bundles generation is easy and similar to generating an APK.

-> In Android Studio, select the “Build” Tab=> Click on ‘Generate Signed App Bundle/ APK’ and follow the steps mentioned in the dialog.

-> Select Android App Bundle Radio Button => Click Next.

-> Fill up your keystore details and add the jks file path.

-> Select the checkbox and set the file path for an encrypted key which will be used as a security key for enrolling published apps in Google Play App Signing on Play Console => Click Next.

-> Select Release => Click Finish.

This key needs to be used only the first time you upload the bundle.

Test your App bundle

There are two ways:

  1. Using Internal Test track/channel on Play Console. This will help during your QA.
  2. Using BundleTool, during the development phase.

In case you need help with testing the bundle you can know more here.

You are now ready to publish your first app bundle!

I got this image from Google :)

Next Steps…

If this got you interested, you can read about:

Dynamic Delivery

On-Demand Features

References

I hope you enjoyed reading this article. Do let me know if you have any suggestions for me.

Thanks for reading!!

--

--

Drithi Shetty
Tata CLiQ Technology

Android developer, music enthusiast, singer, dancer, an amateur painter & a big foodie! :)