Android App Bundle : New way to reduce APK size

Brijesh Gupta
Cashify Engineering
3 min readMay 12, 2018

Android App Bundle is a new upload format of application on play store. It includes DEX bytecode, resources and manifest which are required to generate different and optimise APK according to a user. User has different CPU architectures and language preferences so it supports dynamic delivery. Google play generate APK according to user preferences from app bundle so developer no need to maintain multiple APK.

Benefits of App Bundle

App Bundle supports Dynamic delivery in which it follows split APKs mechanism. Split APKs mechanism came into play with Instant App available on Android 5.0 (API Level 21) or higher. As the name suggests it splits APK into three major APKs which can dynamically serve according to their type.

Base APK as the name suggests it is base which includes code and resources which other Split APKs can access. It provides the basic functionality of your app when the user installs Apk for the first time from play store.

Configuration APKs consists of native libraries, CPU architecture, resources and language preference . So, there are many configuration APKs depending on CPU architecture, resources for different screen density and language preferences of the user. When the user downloads the application from play store, user specific configuration APK is installed along with the Base APK.

Dynamic Feature APKs contains code and resources corresponding to different screen density. It gets downloaded and installed only when it is required.

Showing Simple and Split APKs Mechanism

The first diagram shows the Base APK and specific Configuration APK which gets installed at the time of download from play store. Following it, dynamic APK and specific Configuration APK are installed on demand. It is also called Flexible serving mechanism.

Split APK supports Android 5.0 and higher, so it reduces Apk size on Android API Level above 20.

Developer doesn’t need to manage multiple APKs for different screen densities and cpu architectures . Consequently, this reduces APK size.

Split APK mechanism came into play for the first time with the launch of Instant App feature which supported Split APK and dynamic delivery of content for the first time . So Android App bundle also supports instant app and the split mechanism to achieve it.

Steps to generate App Bundle

First go to Build > Generate Signed Bundle / APK and select Android App Bundle.

Option to select App Bundle

Next step is to select deploy key and enter the password.

Finally, put all the detail and select flavour to generate App Bundle. Which will be uploaded on play store.

Test you App Bundle

After having successfully generated App Bundle, you can test its behaviour on the user device and also generate APK according to a user with the help of bundletool. While it is generating APK file for a device it also includes set of all APKs which are required for user.

bundletool build-apks --bundle="app bundle path" --output="output path"
--ks=/path/keystore.jks
--ks-pass=pass:password
--key-pass=pass:password

--

--

Brijesh Gupta
Cashify Engineering

Senior Software Engineer — Mobile | Tech Lover | AI | Machine Learning