Geek Dashboard

How-To's, Smartphones, News and Reviews

  • Home
  • News
  • Smartphones
    • Android
    • iOS
  • Computers
    • Windows
    • macOS
  • Internet
  • Reviews
You are at Home » Computer

How to Generate and Extract APK Files from Android App Bundle (AAB)

Last Updated on May 17, 2022 by Amar Ilindra 16 Comments

In Google, I/O 2018, Android App Bundle, a new file format was introduced to distribute Android apps via Google Play. Later in 2019, Google started recommending developers to upload new apps/updates in .aab format instead of traditional .apk. The main objective of Android App Bundle is reducing the size of the app you download from Play Store. Technically it is a collection of different APKs generated dynamically for various device configurations. If you want to install .aab file outside of Play Store, you need to first extract APK files from AAB and install them manually on your Android device.

Unlike traditional .apk files, it is not possible to share or sideload the .aab file for testing. When you upload the .aab file in your Google Play Console, an optimized .apk file will be dynamically generated based on the user device configuration.

For example, if an Android app has multiple “strings.xml” files for different languages and your device default language is set to English. A .apk file will be generated dynamically for your device excluding all other language files to reduce the .apk size.

Notification History Log Android App Bundle Size Difference

This feature comes handly from a user point of view but for developers and testers, it added more headache. Since it is not possible to install a .aab file like APKs, you need to either first upload it to Play Store for testing or manually generate APK files from Android App Bundle (.aab). Once multiple APKs or universal APK file is extracted from .aab, you can install the app on different device configurations.

Converting Android App Bundle (.aab) to APK File

After generating the Android App Bundle from Android Studio or from your favorite IDE, you need to first test how the generated APKs behave when deployed on local mobiles. The quickest way to do this is converting .aab file to APK and by installing it in the traditional way.

To extract APK files from Android App Bundle, we’re using bundletool, which is an opensource command-line tool available on GitHub. This tool is for manipulating the Android App Bundle to generate APK set archive (.apks) file. Once the “.apks” file is generated using bundletool, we can extract the APK files by changing the file to .zip format.

Here is how you can use bundletool to generate .apks archive file from Android App Bundle and extract .apk files:

convert aab to apk

Step 1: Download bundletool command-line tool

First things first, download the latest version of bundletool jar file from GitHub and save it inside a folder on Desktop. At the time of writing this article, the latest version of bundletool is 0.10.2 and for simplicity, change the file name from bundletool-all-0.10.2.jar to bundletool.jar

Download bundletool.jar to extract APK from AAB

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

Copy your Android App Bundle (.aab) file to the same folder where you have downloaded the bundletool.jar in previous steps. This is very important and you must make sure both bundletool.jar and .aab file is in the same folder every time you run the bundletool command.

As shown in the screenshot, the name of my Android App Bundle is nhl.aab and both “bundletool.jar” and “nhl.aab” files are in the same folder. For this tutorial, we are using the AAB file of our Notification History application.

bundletool.jar and app bundle placed in the same folder

Now open the Command Prompt (Windows) or Terminal (Mac) and change the directory to your Desktop folder using the CD command. To generate an APK set archive (.apks) file containing different APK files of all devices configurations your app supports, run the build-apks command as shown below.

java -jar bundletool.jar build-apks --bundle=nhl.aab --output=nhl.apks

  • bundletool.jar – The name of .jar file you downloaded from GitHub
  • nhl.aab – Your Android App Bundle file name
  • nhl.apks – The name of the output file. It is a .apks file. Don’t confuse it with the traditional .apk file.

After running the above command, a new file with the name “nhl.apks” will be created in the same folder. This is an APK archive file and by extracting it, you will get multiple APK files for different device configurations.

APKs archive file with .apks file extension

Step 3: Extract APK Files

Once the “nhl.apks” file is generated, it is very easy to extract APK files from it. All you have to do is, rename the “nhl.apks” file to “nhl.zip” and extract it normally using ZIP file extractor. You will now find a lot of APK files in splits and standalones folders.

Extracting APKs from AAB

Now you have successfully converted the .aab file to .apk files and you can install them on your device normally. Technically, this is how you can install .aab file on an Android device.

Wait it’s not over yet. Did you notice any problem with the above command? Yes, it is generating plenty of Debug APK files and you are not sure about which one you need to install? What if you want signed APKs or a universal signed APK from Android App Bundle. Fortunately, bundletool comes with different flags for extracting required APK from .aab file.

Here is a table with different bundletool flags and its usage.

Flag Status Explanation
–ks=

–ks-pass=pass:

–ks-key-alias=

–key-pass=pass:

Optional Keystore Path
Keystore password
Key alias
Key alias password
–mode=universal Optional To generate a single Universal APK file
–overwrite Optional Overwrites the output .apks file if same file name exists

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

Generating Signed APKs using your Keystore

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

java -jar bundletool.jar build-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 an “nhl.apks” file and you need to rename it to “nhl.zip” and extract the zip file to see signed apks in both splits and standalone folders.

Generating a Universal APK from Android App Bundle

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

java -jar bundletool.jar build-apks --bundle=nhl.aab --output=nhl.apks --mode=universal

This command will generate nhl.apks file and again you need to rename it to nhl.zip and extract it to get universnal.apk file.

Overwriting existing .apks file

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

java -jar bundletool.jar build-apks --bundle=nhl.aab --output=nhl.apks --overwrite

Extracting Signed Universal APK file from 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 already available.

java -jar bundletool.jar build-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 “nhl.zip” and extract it to find the signed “universal.apk” file.

extracting universal APK from App Bundle

There are few more advanced flags like --device-spec, --connected-device, --device-id to generate APK and install Android App Bundle on connected or specific device configurations. Apart from them you also have extract-apks and get-size total commands for more use-cases. You can find more about them at Android Developer Bundletool page here.

Also Read: How to Fix DF-DFERH-01 – Error retrieving information from server in Google Play

Conclusion for extracting APK files from AAB

To conclude, the one possible way to install Android App Bundle (.AAB) is uploading it directly on Google Play Store for a set of testers or use the bundletool command to convert .aab to .apk file. If your app is big and has a lot of active users, use the bundletool to test the app on different device configurations and roll out the updates slowly. However, if your app is new, you can prefer adding the App Bundle in closed alpha to gather the feedback.

In the long run, it is always better to extract APKs from the App Bundle first. And test them manually on local devices before submitting the update from your Google Play Console.

#Android#APK#App Bundle#Development#Play Store
Posted inComputer

Spread the Word!

Avatar for Amar Ilindra

Amar Ilindra Facebook Twitter LinkedIn Instagram GitHub

Amar Ilindra is a tech-savvy individual who is passionate about gadgets and new technology. He is a full-stack developer who enjoys experimenting with technology and sharing his experiences through blogging. When he's not writing, he devotes his time to creating practical web and mobile applications for both Android and iOS platforms.

Related articles

Mobiles

How to Enable Voice Call Option Manually in WhatsApp

how to enable voice call in WhatsaApp
News

Lenovo Tab 6 5G Announced with 10.3-Inch Display and Snapdragon 690 5G Chipset

Lenovo Tab 6 5G
News

Lava Agni 5G Launched with MediaTek Dimensity 810 SoC and Quad Cameras in India

Lava Agni 5G

Comments

  1. Avatar for SyamSyam says

    October 18, 2022 at 2:38 PM

    After renaming the .apks to .zip, I am unable to open the file as it says that “You do not have permission to open the document”. How to open the file now?

    Reply
  2. Avatar for SyamSyam says

    October 18, 2022 at 10:11 AM

    Thank you for the detailed article. This article explains about how to generate signed .apk form .aab. But we need to upload signed .aab to playstore. Can you please let me know how to generate signed .aab?

    Reply
    • Avatar for Amar IlindraAmar Ilindra says

      October 18, 2022 at 6:15 PM

      You can generate the signed AAB from Android Studio. Go to Build – Generate Signed Bundle / APK… and choose Android App Bundle. Click Next.

      Now select your Key store file and type Key store password, Key alias, and Key password. Now select Release and hit Finish.

      Reply
  3. Avatar for Akshay KhandizodAkshay Khandizod says

    March 17, 2022 at 4:23 PM

    AAB to APK Converter

    I have developed a windows tool for converting .aab files to .apk in Python.

    It supports creating both debug and signed APK which can be directly installed to default android devices connected through USB.
    It uses Google’s Bundle Tool in the backend.

    Source Code: https://github.com/idzresearch/aab-to-apk-converter

    This is the first tool that I have developed, Hope it is useful. I am open to suggestions and bug reports.

    Reply
    • Avatar for Amar IlindraAmar Ilindra says

      March 17, 2022 at 8:17 PM

      Great tool Akshay. It was a good start.

      Consider improving the UI. Check Dribbble for inspiration.

      Reply
    • Avatar for George BirbilisGeorge Birbilis says

      May 15, 2022 at 3:34 AM

      Hi Akshay, does your tool generate universal APK?

      Reply
  4. Avatar for JeswinJeswin says

    July 1, 2021 at 7:58 PM

    Rename the .aab file to .xapk and Install it using apkpure app…..
    If it is not working, install the app directly from apkpure.
    Download the app from apkpure.com

    Any way it is not recommended to install apps from third party sources

    Reply
  5. Avatar for majhi kalajimajhi kalaji says

    June 24, 2021 at 4:09 PM

    helps me a lot… thanks

    Reply
  6. Avatar for humptyhumpty says

    May 30, 2021 at 1:26 AM

    Kudos, This is saved me a lot of time!

    btw,
    (typo -ks=keystore.jks –ks=keystore.jks)

    Reply
    • Avatar for Amar IlindraAmar Ilindra says

      May 30, 2021 at 8:09 PM

      Glad you find the article helpful.

      I couldn’t understand the typo you suggested. Can you please help me in finding the typo?

      Reply
      • Avatar for George BirbilisGeorge Birbilis says

        May 15, 2022 at 3:23 AM

        the typo is in the last combined command, it says “-ks” instead of “--ks“

        Reply
        • Avatar for Amar IlindraAmar Ilindra says

          May 17, 2022 at 11:06 AM

          Thanks, George Bribilis,

          I fixed the typo.

          Reply
  7. Avatar for santosh Kudalkarsantosh Kudalkar says

    December 3, 2020 at 4:59 PM

    Very Nice Article, you explained very well. Only one thing I didn’t understand how you generated keystore.jks file in the folder. Can you please explain that.

    Reply
    • Avatar for Amar IlindraAmar Ilindra says

      December 4, 2020 at 12:15 PM

      keystore.jks not generated. It is your original Keystore file. You need to either paste it manually into your folder OR provide the full file path.

      Reply
      • Avatar for nathnath says

        February 23, 2021 at 6:59 PM

        Hi Amar How to generate a keystorefile

        Reply
        • Avatar for Amar IlindraAmar Ilindra says

          May 30, 2021 at 8:07 PM

          You can generate the Keystore file from Android Studio. Select Build and then choose Generate Signed APK option. You will get a dialog to choose the existing Keystore along with a button to create a new Keystore file.

          You just need to provide the basic details like organization name, address, alias, password, etc.

          Note: Please make sure you remember the password or store it somewhere else. Resetting it later is a headache or may be impossible too.

          Reply

Comment Policy:

The comments section is aimed to help our readers in case of any questions or you can even appreciate us for our hard work. Every comment is strictly moderated before approving it.

Your name and comment will be visible to the public. Never share your personal information in the comments section.

Leave a Reply Cancel reply

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

Over 1,30,286+ Followers

Join to get latest updates from Geek Dashboard

Facebook Twitter Telegram Pinterest YouTube Instagram

Recently Published

  1. Lenovo Yoga 9i 2-in-1 Laptop with 13th Gen Intel Core i7 Launched in India

  2. Lenovo Tab P11 5G Launched with 11-inch 2K Display and Snapdragon 750G SoC in India

  3. How To Select All Photos on iPhone and iPad Quickly

  4. iQOO 11 5G with Snapdragon 8 Gen 2 SoC and 120W Fast Charging Launched in India

  5. Realme 10 Officially Launched with 90Hz AMOLED Display and Dual Cameras in India

Geek Dashboard Placeholder

Download the apps and never miss a story from us

We put a lot effort and resources in writing our articles and we believe it is our responsibility to satisfy your tech hunger. We will keep you filled forever!

  • Get Geek Dashboard App from Google Play
  • Get Geek Dashboard App from Chrome Web Store
Geek Dashboard Logo

At Geek Dashboard, we are dedicated to bringing you the latest and greatest in technology news, reviews, and how-to guides. From smartphones to laptops, and everything in between, we've got you covered.

Got a Tip? Write In tip@geekdashboard.com

© 2012 - 2023 · Geek Dashboard, product of ikva eSolutions

Blog Advertise About Jobs Contact Privacy Policy Write For Us T&C Office Setup

No dogs were injured while working on this website because we love them