Friday, June 21, 2019

Missing Guide for App Bundles

App Bundles is an amazing feature for Android Developers. It helps reduce the app size for quicker downloads without having to worry about building for every architecture separately. Bundletool provides command line too to help with testing App Bundles before publishing the app.

Bundletool docs seem to miss critical information to complete testing for developers today. This guide hopes to fill the missing gaps in bundletool docs and help developers migrate to App Bundles.

This blog post mainly covers 2 crucial missing options in bundletool:


  1. How to Run bundletool ?
  2. How to test real production APKs?

Running bundletool: You can download latest version of bundletool from Github. Note that this includes a jar file with name bundletool-all-X.Y.Z.jar (Where X.Y.Z indicates the version number of the bundletool). You can just bundletool as a jar file. 

Example: java -jar bundletool-all-0.10.0.jar build-apks --bundle=app.aab --output=myapks.apks


This will build single file with all required APKs for all architectures and screen sizes.

Now how to you install the required APK on your device to test the APK? Its a simple bundletool command.

Example: java -jar bundletool-all-0.10.0.jar install-apks --apks= myapks.apks


This will ensure right APK is installed for your test device. In case adb is not your system path make sure to specify where the path is for your adb.

Example: java -jar bundletool-all-0.10.0.jar install-apks --adb=/ADBABSPATH/adb --apks= myapks.apks

The problem with this is bundletool creates APKs that are signed with the debug keystore found in your user path. So how to create APKs with release signatures? bundletool has the option to generate APKs with release signature. 

Example: java -jar bundletool-all-0.10.0.jar build-apks --bundle=app.aab --output= myapks.apks --ks=/PATHTOKEYSTORE/YOURKEYSTORE.keystore --ks-pass=pass:PASSWORD1 --ks-key-alias=yourkeyalias --key-pass=pass:PASSWORD2

Hope this helps while migrating from APKs to App Bundles for you.