How to Convert AAB File to APK

How to extract an APK file from an AAB and how to convert an AAB to APK with our guide. Android App Bundle, is a new file format for distributing Android apps via the Google Play Store.

How to Convert AAB File to APK
How to Convert AAB File to APK

Introduced in 2019, Google began advising developers toupload new apps and updates in .AAB format instead of the traditional .APK.

How to Convert AAB File to APK

The main goal of the Android App Bundle is toreduce the size of the app downloaded from the Play Store. Technically it is a collection of different dynamically generated APKs for various device configurations.

If you want to install the.AAB file outside the Play Store, you must first extract the APK files from AAB and manually install themon your Android device.

Unlike traditional .APK files,it is not possible to share or transfer the .AAB file for testing. When you upload the .AAB file to your Google Play Console, an optimized .APK file will be dynamically generated based on the user’s device configurations.

For example, if anAndroidapphas multiple “strings.xml” filesfor different languages ​​and the default language of the device is English.

An .APK file will be dynamically generated for your device excluding all other language files to reduce the .APK size.

This feature is useful from the user’s perspective, but for developers and testers it added more headaches. Sinceit is not possible to install an .aab file like APKs, you must first upload it to Play Store for testing or manually generate APK files from Android App Bundle (.AAB).

Once you haveextracted multiple APKs or universal APK files from .AAB, you can install them directly on different device configurations. A not too simple procedure is already available, and in the future it could be updated and optimized, here’s how

How to convert Android App Bundle (.AAB) to APK file

After generating the Android App Bundle from Android Studio or your favorite IDE, you first need to test how the generated APKs behave when deployed to local mobile devices. The quickest way to do this is toconvert the .aab file to APKand install it the traditional way with a file manager.

To extract the APK files from the Android App Bundle, we will use the free, open source and command line programbundletoolavailable on GitHub. This tool is used to manipulate the Android App Bundle to generate APK set archive (.apks) files.

Once the “.apks” file has been generated using bundletool, we can extract the APK files by modifying the file in .zip format. Here’s how you canuse bundle tool to generate .apks archive files from Android App Bundle and extract .apk files.

Step 1: Download the bundle tool

First,download the latest version of the bundletool JAR file from GitHub and save it in a folder on your desktop and for simplicity change the file name frombundletool-all-X.XX.X.jartobundletool.jarso that you can easily searchable.

Step 2: Generate the APK Set Archive (.apks) file from .aab

Copy your Android App Bundle (.aab) fileto the same folder where you downloaded bundletool.jar previously.

This is very important and you need to make sure thatboth the bundletool.jar and .aab file are in the same folderevery time you run the commandbundletool.

As shown in the screenshot, the name of the Android App Bundle isnhl.aaband both the “bundletool.jar” and “nhl.aab” files are located in the same folder.

Now open Command Prompt (Windows) or Terminal (Mac) and change directory to Desktop folder usingCDcommand. To generate an APK set archive file (.apks) containing several APK files of all device configurations supported by your app, run the commandbuild-apksas shown below.

java -jarbundletool.jarbuild-apks --bundle=nhl.aab--output=nhl.apks

  • bundletool.jar– The name of the .jar file downloaded from GitHub
  • nhl.aab– The filename of your Android App Bundle
  • nhl.apks– The name of the output file. It is an .apk files. Do not confuse it with the traditional .apk file (add the “s”)

After executing the above command, a new file with the name ”nhl.apks”will be created in the same folder . This is an APK archive file that you need toextractwith the file compression program whereyou will get multiple APK filesfor different device configurations.

Step 3: Extract the APK files

Once the “nhl.apks” file is generated, it is very easy to extract the APK files from the main file. All you have to do is, rename the “nhl.apks”file to “”and extract it normally using ZIP file extractor like 7Zip, WinRAR or WinZip. You will now find many APK files in separate and standalone folders.

Now that you havesuccessfully converted the .aab file to .apk fileand you can install them normally on your device. Technically, this is how you caninstall the .aab file on an Android device.

Problems after extracting the APK file from the AAB

Wait, it’s not over yet. Did you notice any problems with the above command? Yes, it is generating a lot of debug APK files and you are not sure which one you need to install? Or you wantsigned APKs or a universal signed APKfrom Android App Bundle.

Fortunately, bundletool comes with several flags for extracting the required APK from the .aab file. Here is a table with different flags of bundletool and its use.

–Ks = –ks-pass = pass: –ks-key-alias = –key-pass = pass:OptionalKeystore Path
Keystore password
Key alias
Key alias password
–Mode = universalOptionalTo generate a single Universal APK file
–OverwriteOptionalOverwrites the output .apks file if same file name exists

Let’s take a look at how to use these flags in conjunction with the bundletool command.

Generate signed APKs using the Keystore

To generate APK files signed with your keystore file, run the following command.

java -jarbundletool.jarbuild-apks --bundle=nhl.aab--output=nhl.apks--ks=keystore.jks--ks-pass=pass:your_keystore_password--ks-key-alias=your_key_alias--key-pass=pass:your_key_password

This will again generate a “nhl.apks” file and you’ll need to rename it to “” and extract the zip file to see the signed apks in both separate and standalone folders.

Generate universal APKs from Android App Bundle

If you want to generate only one APK from your .aab file, run the following command.

java -jarbundletool.jarbuild-apks --bundle=nhl.aab--output=nhl.apks--mode=universal

This command will generate the nhl.apks file and again you will need to rename it to and extract it to get theuniversnal.apkfile .

Overwrite the existing .apks file

If you want to overwrite the old .apks file with the new one, simply add the –overwrite flag to your command as shown below.

java -jarbundletool.jarbuild-apks --bundle=nhl.aab--output=nhl.apks--overwrite

Extract universal APK file signed by Android App Bundle

Now let’s combine all the above flags to generate a single universal APK file and also overwrite the existing APK archive if it’s already available.

java -jarbundletool.jarbuild-apks --bundle=nhl.aab--output=nhl.apks--overwrite --mode=universal -ks=keystore.jks--ks-pass=pass:your_keystore_password--ks-key-alias=your_key_alias--key-pass=pass:your_key_password

After running this command, you will need to rename the generated “nhl.apks” file to “” and extract it to find the signed “universal.apk” file.

There are some more advanced as a flag--device-spec,--connected-device,--device-idto generate and install APK Android App Bundle of configurations or specific connected devices. Besides them you also haveextract-apksandget-size totalcommands for multiple use cases.

You can find more information about them on the Android Developer Bundletool page here.

Conclusion extracting APK files from AAB and Video Guide

Finally, the only possible way to install the Android App Bundle (.AAB) is to upload it directly to the Google Play Store for a test set or use the command bundletoolto convert the .aab file to .apk.

If your app is large and has many active users, use the bundle tool to test the app on different device configurations and roll out updates slowly. However, if your app is new, you may prefer to add the App Bundle in Closed Alpha to collect feedback.

If you didn’t understand or skipped a few steps, here is thevideothat explains all the steps onhow to generate or extract an APK file from the Android App Bundle (AAB) file.

Leave a Reply

Your email address will not be published. Required fields are marked *