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.
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.
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?
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.
Here is our complete deployment build script:
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_QA - This 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.
https://www.brightec.co.uk/ideas/google-playstore-and-automated-deployment
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#authorizingrequests - The HTTP/REST tab
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#callinganapi
https://developers.google.com/android-publisher/api-ref/edits/bundles/upload
Search over 200 blog posts from our team
Subscribe to our monthly digest of blogs to stay in the loop and come with us on our journey to make things better!