Google PlayStore and automated deployment with AAB

Updating our deployment scripts to use Android App Bundles

Alistair Sykes
Aug 5 · 3 min read


The Android App Bundle was introduced at 2018’s Google I/O event. It’s the new official publishing format for Android apps. Google introduced it to reduce file sizes for users and introduce a few new features.

Coined Dynamic Delivery, Google will use an AAB to generate a more targeted APK file to delivery to the user. For example, they will only serve MDPI devices with MDPI resources.

Existing Scripts

Previously, I have discussed our automated deployment in this post. We use the Google Play Developer API via a bash script, to automate our deployment.


To now use AAB we had to make a couple of updates to our script.

Package name and version code

Previously our script used the APK to determine the package name and version code of the app. This meant our script could be used in different projects, without any extra configuration.

With AAB this is more difficult since we don’t have an APK to extract this information from. You could instead use environment variables to supply your script with this information. We decided to use the bundletool to get this information.

We use the bundletool to generate a universal (not device-specific) APK file. Then we extract the information the same way we before.

It’s worth noting the impact to build times, in comparison to environment variables. Is the generic deployment script worth the cost of a slightly extended build time?

Uploading AAB

The upload phase of the script had a few minor tweaks.

The HTTP request has a different Content-Type and Url but behaves the same as before.

All together

Here is our complete deployment build script:

Circle CI

We currently use CircleCi as our CI system. To call this script within a job:

We have to install the bundletool as it doesn’t come bundled in our docker image. We also need to make sure we have access to our keystore file, which we download using a URL to our private storage.

There are a couple of environment variables to be aware of:

COMMAND_CREATE_AABS_DIST_QAThis is the command used to create our AAB. We use an environment variable so that we don’t have to customise our config for different projects (with different flavour configurations). An example might be: ./gradlew bundleLiveApi ; AAB_PATH=$(find . -path “*/outputs/*Release*/*.aab” -print -quit) ;

PLAYSTORE_SERVICE_KEY — This is the service account key used to access the PlayStore.


Hopefully, this helps you to update your deployment process to make use of AAB and all its benefits.

References — The HTTP/REST tab

Also checkout

Previous Post

Originally published at

The Startup

Medium's largest active publication, followed by +502K people. Follow to join our community.

Alistair Sykes

Written by

Mobile app developer, focusing on Android. Working at Brightec ( Links:

The Startup

Medium's largest active publication, followed by +502K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade