Geek Dashboard

How-To's, Smartphones, News and Reviews

  • Phone Finder
    Phone
    Finder
  • Compare Phones
    Compare
    Phones
  • Viwe All Phone Comparisons
    View All
    Comparisons
  • Home
  • News
  • Smartphones
    • Android
    • iOS
  • Computers
    • Windows
    • macOS
  • Internet
  • Reviews
  • Phone Finder
    • Brands
You are at Home » Computer

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

Last Updated on March 27, 2020 by Amar Ilindra 3 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!

Amar Ilindra Facebook Twitter LinkedIn Instagram GitHub

Amar Ilindra is a gadget freak, tech enthusiast and full stack developer. He loves to try everything with technology and blog about his tech experience. Apart from writing, he spends most of this time developing useful web apps and mobile applications for Android and iOS.

Related articles

Mobiles

Top 10 Best Beauty and Fashion Apps for Virtual Makeup

beauty and fashion apps for virtual makeup
News

Oppo Find X Launch Set for Tomorrow; Tipped to have 93.8% Screen-to-Body Ratio

News

HTC Wildfire E3 Launched with Helio P22 SoC and 4,000mAh Battery

HTC Wildfire E3

Comments

  1. santosh 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
    • Amar 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
      • nath says

        February 23, 2021 at 6:59 PM

        Hi Amar How to generate a keystorefile

        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 *

Phone Finder

Brands

  • Samsung 43
  • Xiaomi 38
  • Nokia 33
  • Motorola 33
  • Huawei 28
  • Asus 25
  • Oppo 25
  • Apple 19
  • Meizu 18
  • Vivo 17
  • Microsoft 12
  • BlackBerry 12
  • OnePlus 9
  • Google 4
  • Acer 2
  • Realme 1

Latest Phones

  • Asus Zenfone 6 (2019) Asus Zenfone 6 (2019) ₹39,999.00
  • Samsung Galaxy A70 Samsung Galaxy A70 ₹28,500.00
Notification History Log for Android

Trending Topics

  1. Redmi Note 10 Series Users Encounter Screen Flickering Issues in India

  2. Samsung Smart Monitors M5 and M7 with OTT Apps Launched in India

  3. Apple Find My App Introduces Third-Party Product Support for Tracking

  4. Realme C20, C21 and C25 Launched in India Starting at Rs. 6,999

  5. WhatsApp to Soon Allow Transferring Chats Between Android and iOS Devices

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

Geek Dashboard, a technology blog strives to produce high-quality tech for our readers. Here you will find the latest updates on trending tech news, unbiased product reviews, and how-to guides on various gadgets.

Got a Tip? Write In tip@geekdashboard.com

© 2012 - 2020 · 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