Creating APKs from AAB Using BundleTool

Creating APKs from AAB Using BundleTool

Written by
Written by

Parth V.

Post Date
Post Date

Jan 05 2026

shares

 

Why Generate APK from AAB in Real Projects?

Production-Equivalent Testing

When you generate an APK directly from the AAB, you are testing the same artifact that Google Play uses to create device-specific APKs.

Faster Verification Without Rebuilds

A common release-time question is:
“Is this build definitely pointing to production?”

By generating an APK from the existing AAB, verification becomes instant: install, validate, and proceed with confidence.

Client, QA, and Store Readiness

APKs generated from AAB are ideal for:

This approach reduces rejections, review cycles, and last-minute surprises.

Step 1: Generate an AAB File

Option 1: Using Android Studio

Option 2: Using Gradle Configuration

release {
  storeFile file('PATH_TO_KEYSTORE_FOLDER/sst.jks')
  storePassword 'STORE_PASSWORD'
  keyAlias 'KEYSTORE_ALIAS'
  keyPassword 'KEY_PASSWORD'
}
release ./gradlew clean
./gradlew bundleRelease

Note: The same signing configuration used for Play Store submission must be used when generating APKs from the AAB.

Step 2: Install BundleTool

To generate APK from AAB, Google provides BundleTool. BundleTool is the same tool used internally by Google Play to convert app bundles into installable APKs. Using it locally allows you to reproduce Play Store behavior with high fidelity.

Install using Homebrew:

 

brew install bundletool

Or download it directly from the official GitHub repository.

Step 3: Generate APK from AAB

When bundletool generates APKs from your app bundle, it creates an APK Set Archive (.apks), which contains all generated APKs.

bundletool build-apks \
  --bundle=PATH_TO_AAB_FOLDER/app-release.aab \
  --output=PATH_TO_OUTPUT_FOLDER/my_app.apks \
  --ks=PATH_TO_KEYSTORE_FOLDER/sst.jks \
  --ks-pass=pass:KEYSTORE_PASSWORD \
  --ks-key-alias=KEYSTORE_ALIAS \
  --key-pass=pass:KEY_PASSWORD \
  --mode=universal

Command Explanation:

Step 4: Extract Universal APK

Automate the Entire Process

To save time and avoid manual errors, you can automate everything using a shell script.

Example: generate_apk.sh

#!/bin/bash

AAB_PATH="PATH_TO_AAB_FOLDER/app-release.aab"
OUTPUT_APKS="PATH_TO_OUTPUT_FOLDER/my_app.apks"
KEYSTORE_PATH="PATH_TO_KEYSTORE_FOLDER/sst.jks"
KS_PASS="KEYSTORE_PASSWORD"
KEY_ALIAS="KEYSTORE_ALIAS"
KEY_PASS="KEY_PASSWORD"

bundletool build-apks \
 - bundle=$AAB_PATH \
 - output=$OUTPUT_APKS \
 - ks=$KEYSTORE_PATH \
 - ks-pass=pass:$KS_PASS \
 - ks-key-alias=$KEY_ALIAS \
 - key-pass=pass:$KEY_PASS \
 - mode=universal

cd "$(dirname "$OUTPUT_APKS")"
cp "$(basename "$OUTPUT_APKS")" my_app.zip
unzip -o my_app.zip -d extracted_apk

echo "Universal APK generated at: extracted_apk/universal.apk"

▶️ Run the Script

chmod +x generate_apk.sh
./generate_apk.sh

Final Thought

Although Android App Bundles are mandatory for Play Store submission, APK testing remains a critical part of a reliable release process.