App Bundles & bundletool
An Android App Bundle (.aab) is a publishing format, not an installable one. It contains all of the app's code and resources organised by module and configuration; Google Play then generates split APKs tailored to each device (its screen density, CPU architecture, language and Android version) and signs them. Users download less, and Play has required bundles for new apps since August 2021.
.aab what you upload
├── base/manifest/AndroidManifest.xml (protobuf format, not binary XML)
├── base/dex/classes.dex
├── base/res/…, base/resources.pb
├── base/lib/arm64-v8a/…, base/lib/x86_64/…
├── BUNDLE-METADATA/… e.g. the R8 mapping file
└── BundleConfig.pb how to split
│
▼ Play (or bundletool) generates
base-master.apk + base-arm64_v8a.apk + base-xxhdpi.apk + base-en.apk … what a device installsBuilding a bundle
bundle<Variant> is the bundle counterpart of assemble<Variant>. The bundle is signed with the variant's signing config, which for Play means your upload key:
mkdir -p hello/app/src/main/java/com/example/hello hello/app/src/main/res/values hello/app/src/main/res/values-de && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
cat > app/src/main/AndroidManifest.xml <<'XML'
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="@string/app_name">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
XML
echo '<resources><string name="app_name">Hello</string></resources>' > app/src/main/res/values/strings.xml
echo '<resources><string name="app_name">Hallo</string></resources>' > app/src/main/res/values-de/strings.xml
cat > app/src/main/java/com/example/hello/MainActivity.java <<'JAVA'
package com.example.hello;
public class MainActivity extends android.app.Activity {
@Override protected void onCreate(android.os.Bundle state) {
super.onCreate(state);
android.widget.TextView view = new android.widget.TextView(this);
view.setText(R.string.app_name);
setContentView(view);
}
}
JAVA
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }
android {
namespace = "com.example.hello"
compileSdk = 36
defaultConfig { applicationId = "com.example.hello"; minSdk = 24; targetSdk = 36; versionCode = 12; versionName = "1.3.0" }
signingConfigs {
create("upload") {
storeFile = file(System.getenv("HOME") + "/release.jks") // demo only: read secrets from properties
storePassword = "learner-pass"; keyAlias = "release"; keyPassword = "learner-pass"
}
}
buildTypes {
release {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
signingConfig = signingConfigs.getByName("upload")
}
}
}
KTS
gradle wrapper > /dev/null
./gradlew bundleRelease | grep -E 'Task :app:(minify|package|sign|bundle)Release|^BUILD'
AAB=app/build/outputs/bundle/release/app-release.aab
unzip -l $AAB | awk 'NR>3 && $4 != "" {print $4}' | grep -v 'kotlin_builtins' | sort
echo "--- signed by"
keytool -printcert -jarfile $AAB | grep '^Owner'> Task :app:packageReleaseResources
> Task :app:bundleReleaseResources
> Task :app:minifyReleaseWithR8
> Task :app:packageReleaseBundle
> Task :app:signReleaseBundle
> Task :app:bundleRelease
BUILD SUCCESSFUL in 11s
BUNDLE-METADATA/com.android.tools.build.gradle/app-metadata.properties
BUNDLE-METADATA/com.android.tools.build.libraries/dependencies.pb
BUNDLE-METADATA/com.android.tools.build.obfuscation/proguard.map
BUNDLE-METADATA/com.android.tools/r8.json
BundleConfig.pb
META-INF/MANIFEST.MF
META-INF/RELEASE.RSA
META-INF/RELEASE.SF
base/dex/classes.dex
base/manifest/AndroidManifest.xml
base/resources.pb
base/root/META-INF/com/android/build/gradle/app-metadata.properties
base/root/META-INF/version-control-info.textproto
--- signed by
Owner: CN=Ada Lovelace, O=Example, C=GB
Notice:
- The R8 mapping file travels inside the bundle (
BUNDLE-METADATA/…/proguard.map), which is how Play Console deobfuscates crashes without a separate upload. - A bundle is signed with JAR signing (
META-INF/RELEASE.SF/.RSA), because it's an archive for Play, not an APK.keytool -printcert -jarfilereads it;apksignerwon't. - No
resources.arsc: resources are stored as protobuf (resources.pb) so Play can split them.
bundletool: what Play does, on your machine
bundletool is the open-source tool Play uses to turn bundles into APKs. Locally it answers "what will users actually download?" and lets you install a bundle on a test device (bundletool install-apks). build-apks produces an .apks archive (a zip of split APKs plus a table of contents); since those APKs are signed, give it a keystore:
mkdir -p hello/app/src/main/java/com/example/hello hello/app/src/main/res/values hello/app/src/main/res/values-de hello/app/src/main/res/values-fr && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
cat > app/src/main/AndroidManifest.xml <<'XML'
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="@string/app_name">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
XML
echo '<resources><string name="app_name">Hello</string></resources>' > app/src/main/res/values/strings.xml
echo '<resources><string name="app_name">Hallo</string></resources>' > app/src/main/res/values-de/strings.xml
echo '<resources><string name="app_name">Bonjour</string></resources>' > app/src/main/res/values-fr/strings.xml
cat > app/src/main/java/com/example/hello/MainActivity.java <<'JAVA'
package com.example.hello;
public class MainActivity extends android.app.Activity {
@Override protected void onCreate(android.os.Bundle state) {
super.onCreate(state);
android.widget.TextView view = new android.widget.TextView(this);
view.setText(R.string.app_name);
setContentView(view);
}
}
JAVA
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }
android {
namespace = "com.example.hello"
compileSdk = 36
defaultConfig { applicationId = "com.example.hello"; minSdk = 24; targetSdk = 36; versionCode = 12; versionName = "1.3.0" }
buildTypes { release { isMinifyEnabled = true; proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) } }
}
KTS
gradle wrapper > /dev/null
./gradlew -q bundleRelease
AAB=app/build/outputs/bundle/release/app-release.aab
KS="--ks=$HOME/release.jks --ks-pass=pass:learner-pass --ks-key-alias=release --key-pass=pass:learner-pass"
bundletool validate --bundle=$AAB | head -3
bundletool build-apks --bundle=$AAB --output=app.apks $KS
unzip -l app.apks | awk 'NR>3 && $4 != "" {print $4}'
echo "--- download size per device group (bytes)"
bundletool get-size total --apks=app.apks --dimensions=SDK,LANGUAGE | tr -d '\r' | { read -r header; echo "$header"; sort; }
echo "--- one universal APK, e.g. for QA or another store"
bundletool build-apks --bundle=$AAB --output=universal.apks --mode=universal $KS
unzip -l universal.apks | awk 'NR>3 && $4 != "" {print $4}'
unzip -o -q universal.apks universal.apk && apksigner verify --print-certs universal.apk | grep DNApp Bundle information
------------
Feature modules:
toc.pb
splits/base-de.apk
splits/base-de_2.apk
splits/base-de_3.apk
splits/base-fr.apk
splits/base-fr_2.apk
splits/base-fr_3.apk
splits/base-master.apk
splits/base-master_2.apk
splits/base-master_3.apk
--- download size per device group (bytes)
SDK,LANGUAGE,MIN,MAX
24-28,de,18584,18584
24-28,fr,18581,18581
29-31,de,18606,18606
29-31,fr,18602,18602
32-,de,18605,18605
32-,fr,18600,18600
--- one universal APK, e.g. for QA or another store
toc.pb
universal.apk
Signer #1 certificate DN: CN=Ada Lovelace, O=Example, C=GB
The bundle produced a master split plus one language split per locale, and each of them in three flavours (base-master.apk, _2, _3) for three Android version ranges: API 24–28, 29–31 and 32+, where packaging details such as how dex and native code are stored differ. A German phone on Android 14 downloads one base-master and one base-de APK and never the French strings. Real apps also get density splits (drawables per hdpi/xxhdpi) and ABI splits (native .so files per CPU), which is where most of the savings come from. get-size total reports the minimum and maximum download for each combination of the dimensions you ask for; it's a cheap CI metric to track (a sudden jump in download size is a regression worth a red build).
--mode=universal merges everything into one APK, which is useful for QA, for side-loading and for stores that don't accept bundles.
Bundle configuration in Gradle
android {
bundle {
language { enableSplit = true } // default; set false for in-app language pickers
density { enableSplit = true }
abi { enableSplit = true }
}
}Turn off the language split if the app lets users switch language inside the app: otherwise the strings for the newly picked language aren't installed (or use the Play Core API to request them).
Test yourself
Why can't you install an .aab file directly on a phone?
- It's encrypted
- It's a publishing format; installable split APKs must first be generated from it (by Play or bundletool)
- It lacks a manifest
- Only emulators accept it
Which bundletool mode produces a single APK containing every language, density and ABI?
- --mode=default
- --mode=universal
- --mode=system
- get-size total
How does Play Console get the R8 mapping file for a release uploaded as a bundle?
- You must email it
- AGP stores it inside the bundle under BUNDLE-METADATA
- It's in the APK's classes.dex
- Play regenerates it