How we automate our AAB deployment to the Google PlayStore
The Android App Bundle was introduced at 2018’s Google I/O event. It continues to be the official publishing format for Android apps. Google introduced it over the APK to reduce file sizes for users and introduce a few new features.
Coined Dynamic Delivery, Google uses the AAB format to generate a more targeted APK file to deliver to the user. For example, only serve MDPI devices with MDPI resources.
After developing your Android app, releasing it, or updating it, can be a lengthy process. Automating this process with Google’s Play Developer API enables Android app developers to conduct releases efficiently and consistently.
To now use AAB we had to make a couple of updates to our bash script, detailed previously in this post.
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.
Further Reading and References
Search over 400 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!