📦➡🤖

Generating Universal .APK Files From Android's .AAB Bundles

Contents

Say for some reason you got yourself a .aab file on your hands when developing for Android and you want to test the app by installing it on your phone without going through PlayStore for whatever reasons.

It could be from Android Studio’s build feature, or some cloud (or cli) app build service like Expo’s EAS it doesn’t matter, as long as you have a keystore and the credentials to the said keysotre, you can convert it into a universal APK.

You Need

  1. The java command available on your command line PATH
  2. The .aab that you hate (or love, idk).
  3. The Keystore and Credentials to the Keystore.

Download Google’s Bundle Tool

To download the latest, go to the Releases Link on the repo, and download the latest bundletool-all-[version].jar jar file.

Link: https://github.com/google/bundletool/releases

You could just use the commandline though, and download the version what was used at the time of this writing.

Terminal window
wget https://github.com/google/bundletool/releases/download/1.15.1/bundletool-all-1.15.1.jar -O ~/Downloads/bundletool.jar

Generate The APK

Terminal window
java -jar ~/Downloads/bundletool.jar build-apks \
--bundle=[BUNDLE_PATH] \
--output=[APK_DIRECTORY]/[SOME_FILENAME].apk \
--mode=universal \
--ks=[KEYSTORE_PATH] \
--ks-pass="pass:[KEYSTORE_PASSWORD]" \
--ks-key-alias="[KEYSTORE_ALIAS]" \
--key-pass="pass:[KEYSTORE_ALIAS_PASSWORD]"
  1. The .apks extension probably feels really weird, but it’s apparently necessary to be explicit that it will be an archive of files not just one apk file.
  2. The pass: part of the passwords is important. Leave as-is, as the literal value pass:
  3. --mode=universal generates universal APKs, otherwise you’ll get a zip file with multiple APKs for multiple architectures.

Extract The .apk File

You will be left with a .apks file in the APK directory that you input in the command above. This file is simply a .zip file with a different extension. You can rename it to a .zip and use your a GUI tool to extract it.

You can also just use the commandline as such:

Terminal window
cd [APK_DIRECTORY]
unzip ./[SOME_FILE].apks