App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to test .aab file on Android device

How to test .aab file on Android device

By Sandra Felice, Community Contributor -

Table of Contents

Android App Bundle or AAB was introduced by Google in 2018 as part of its efforts to reduce the size of the Android apps. With aab, Google Play generates optimized APK files based on the different device configurations based on DRI, CPU architecture, and languages. It then distributes them to different users based on the one that works best for each of the user’s devices through a process called Dynamic Delivery.

What is Android App Bundle (aab)?

An Android App Bundle or aab is a publishing file format that includes all your application’s compiled code and resources. It defers APK generation and signing to Google Play.

The developer uploads the app to the Google Play Store in aab format, with the user downloading it from their smartphone as usual. With a closer inspection, you will find that there is no difference in the way the apps are installed since the smartphone will still download the APK file from the Google Play Store. The difference here lies in what we call resources. Resources are everything in an app that is not a programming code, such as Language files, images, audio, etc.

Why Android App Bundle (aab) was built?

App Size matters to every business:

  • Lower conversion rates
  • Slower downloads
  • Higher uninstalls
  • Lower update rates

Size savings because of Android App Bundles

How does the Android App Bundle work?

In the Universal APK, a developer uploads a Universal APK to Google Play. A user then downloads this Universal APK. The size of the downloaded app will be the same as that of the uploaded app. In the case of the Android App Bundle, Google Play will generate an optimized APK in terms of the size and spec of the user’s device. It also resigns the generated APK file instead of the developers. In this way, a good AAB can save the disk usage of an Android device. As per Google, AAB can save an average of 35% of disk usage as compared to Universal APK.

Let’s take an example:

Assume your smartphone has only Full HD resolution with English as the device language. So, when you are installing any app from the Play Store, you will receive an APK with only Full HD material and an English language pack. With the help of Google’s bundletool tool, AAB files can be locally converted into APK files.

Creating an Android App Bundle (AAB File)

An Android App Bundle can be created either via the command line or Android Studio.

Building on the command line

Open the command line and run the bundle tasks using the below command.

./gradlew bundleRelease

Locate your bundle in your application’s build directory. The default location is app/build/outputs/bundle/release. This bundle needs to be signed using jarsigner using the command

jarsigner -keystore $pathToKeystore app-release.aab $keyAlias

(Replace the keyStore and keyAlias variables with actual values of the keyStore and password). The bundle will be signed and ready for upload to the Play Store.

Building on Android Studio

Step 1:  Go to Android Studio -> Build ->Generate Signed Bundle. Select Android App Bundle on the pop screen and select Next.

Generate Signed Bundle on Android Studio

Step 2: Enter the KeyStore path where the KeyStore is stored or Create a new KeyStore as seen below.

Creating a new KeyStore in Android Studio

Step 4: Select the release mode from the list and select finish.

Creating AAB in Android Studio

Now, you have a signed app bundle ready. In the Destination folder, there will be a .aab file. This is your Bundle file, and this can now be uploaded and published on the Play Store.

How to test Android App Bundle?

After generating your Android App Bundle, you should test how Google Play uses it to generate APKs and how those APKs behave when deployed to a device. 

There are two ways to test your app bundle:

  1. Testing locally using the bundletool
  2. Testing locally via the Google Play Console

In this article, the first method will be used for testing our Android app bundle.

With BrowserStack, one can try using Docs for reference.

Pre-requisites

Following are the prerequisites needed before starting with the testing:

  • An Android test device
  • Any Unzipping tool like 7-zip
  • bundletool

bundletool is an underlying tool that is used by Android Studio and Google Play to build an Android App Bundle, which is then converted into various APKs that are deployed to devices. bundletool is also available as a command-line tool so that one can create app bundles by themselves and recreate Google Play’s server-side build of the app’s APK.

Follow the below steps to test Android App Bundle:

Step 1: Download bundletool from GitHub repository

Step 2: Generate an APK Set archive (.apks) from your app bundle file. To generate an APK set for all device configurations supported by your app, use the following command (both your app bundle file and bundletool should be in the same location for the below command to work):

java -jar "bundletool-all-1.10.0.jar" build-apks --bundle="app-release.aab" --output="app.apks"

The output will be something like this:

Generating APK Set Archive for Testing AAB

The above command will be signed with the debug keyStore value. If you want to give keyStore parameters like keyStore file or pass to generate signed APKs, use the following command:

java -jar "bundletool-all-1.10.0.jar" build-apks --bundle="app-release.aab" --output="app.apks" --ks=<your keystore path> --ks-pass=pass:<your password> --ks-key-alias=<your KeyAlias> --key-pass=pass:<your password> 

You will see .apks file generated in the same folder.

APKs generated using bundletool

Step 3: Check the content of the .apks file by converting the .apks file into zip file and then extracting its contents using 7-zip

Converting APKs to ZIP Files

Step 4: Inside the app folder, you will be able to see a folder called “splits” which consists of a number of APK files. You can also see that the app base module has been split up based on display size, language etc.

Splits Folder containing details of APK files

After generating a set of APKs, bundletool can deploy the right combination of APKs from that set to a connected device.

For example, if you are connected to a device using Android 5.0 (API Level 21) or above, bundletool pushes the base APK, feature module APKs and configuration APKs required to run the app on that device.

Step 5 (Optional): If you are planning to install all the APKs locally from the APK set, use the command (in the folder path where your .apks is present):

bundletool-all-1.10.0.jar install-apks --apks=app.apks

Step 6 (Optional): If you want to generate a device specific set of APKs as discussed above, use the following command (using Pixel XL for my testing):

bundletool-all-1.10.0.jar build-apks --connected-device --bundle=<Path of your aab> --output=<PathForTheOutput>

Generating Device Specific APKs

Step 7 (Optional): If you want to generate a device specific set of APKs as discussed above using JSON files, use the following command:

bundletool-all-1.10.0.jar get-device-spec --output=/tmp/device-spec.json

The above command creates a JSON file for your device in the directory where the tool is located. Based on this JSON file, the bundletool will create a set of APKs. Use the following command:

bundletool build-apks --device-spec=/MyApp/pixelXL.json

--bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks

Test Android Apps on Real Devices

The way ahead

The AAB files are much smaller than the APK files so much so that you will be able to see a 35% reduction in the app size on an average. Another benefit for the developers is increased security since App modification is difficult in this case. Difficulty in App modification lies in the fact that the app signing is mainly done by Google instead of the developers. App updates and development process has also become easier which has led to the prevention of broken updates in the future or even mitigating their effects.

However, no matter whether you choose AAB or APK files to test your Android Apps, it is always advisable to test them on real devices for better accuracy of tests. By testing on a secure real device cloud, like BrowserStack, you get the liberty to test on different devices available in the market, which would help in testing under real user conditions. Hence, you’ll be able to identify bottlenecks in the user experience and resolve them for a seamless and consistent user experience across all devices. 

Moreover, it allows you to automate tests by using frameworks like Appium, and Espresso that can be easily integrated with popular CICD pipelines such as Jenkins, Travis CI, CircleCI, Github, Bamboo, etc. to leverage automation testing in Agile Teams. It also allows QAs to run parallel tests for a faster testing process.

Try Mobile App Testing on BrowserStack

Tags
Automated UI Testing Automation Testing Mobile App Testing Mobile Testing

Featured Articles

Appium Tutorial for Mobile Application Testing

How to Download and Install Appium

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.