An Android App Bundle is a new upload format that includes all your app’s compiled code and resources, but defers APK generation and signing to Google Play.
Google Play’s new app serving model, called Dynamic Delivery, then uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.
Additionally, you can add dynamic feature modules to your app project and include them in your app bundle. These modules contain features and assets that you can decide not to include when users first download and install your app. Using the Play Core Library, your app can later request to download those modules as dynamic feature APKs, and, through Dynamic Delivery, Google Play serves only the code and resources for that module to the device.
Watch the following video for an overview of why you should upload your app using Android App Bundles.
Publishing with Android App Bundles also increases the app size limit to 150MB without having to use APK expansion files. Keep in mind, this limit applies only to the actual download size, not the publishing size. So, users can download apps as large as 150MB and, with dynamic delivery, all of that storage is used for only the code and resources they need to run the app. When you combine this with support for uncompressed native libraries, larger apps, such as games, can reduce disk usage and increase user retention.
If you’re using Android Studio 3.2 or higher, most app projects require little effort to support Dynamic Delivery, and you can build an Android App Bundle in just a few clicks. However, adding dynamic feature modules requires a little more effort and possibly refactoring your app.
This page describes the steps to get started building Android App Bundles and describes some important concepts related to app bundles and Dynamic Delivery.
To build app bundles and support Dynamic Delivery, follow these steps:
Download Android Studio 3.2 or higher—it's the easiest way to add dynamic feature modules and build app bundles.
Add support for Dynamic Delivery by including a base module, organizing code and resources for configuration APKs, and, optionally, adding dynamic feature modules.
Test your app using the following methods:
- Test your Android App Bundle locally using bundletool to generate APKs from your app bundle and deploy them to a connected device.
- Share your app with a URL. This is the fastest way to upload your app bundle and share your app as a Google Play Store link with trusted testers. Additionally, this is the fastest way to test custom delivery options, such as downloading features on demand.
- Set up an open, closed, or internal test.
Enroll into app signing by Google Play. Otherwise, you can't upload your app bundle to the Play Console.
The Android App Bundle format
An Android App Bundle is a file (with the
.aab file extension) that you
upload to Google Play to support Dynamic Delivery.
App bundles are signed binaries that organize your app’s
code and resources into modules, as illustrated in figure 1. Code and resources
for each module are organized similarly to what you would
find in an APK—and that makes sense because each of these modules may be
generated as separate APKs. Google
Play then uses the app bundle to generate the various APKs that are served to
users, such as the base
APK, dynamic feature APKs, configuration APKs, and (for devices that do not
support split APKs) multi-APKs. The directories that are colored in blue—such
lib/ directories—represent code and
resources that Google Play uses to create configuration APKs for each module.
The following list describes some of the app bundle’s files and directories in more detail:
- base/, feature1/, and feature2/: Each of these top-level directories
represent a different module of your app. The
base module for your app is always contained in a
basedirectory of the app bundle. However, the directory for each dynamic feature module is given the name specified by the
splitattribute in the module’s manifest. To learn more, read about the Dynamic feature module manifest.
- BUNDLE-METADATA/: This directory includes metadata files that contain information useful for tools or app stores. Such metadata files may include ProGuard mappings and the complete list of your app's DEX files. Files in this directory are not packaged into your app's APKs.
- Module Protocol Buffer (
*.pb) files: These files provide metadata that helps describe the contents of each app module to app stores, such as Google Play. For example,
BundleConfig.pbprovides information about the bundle itself, such as which version of the build tools were used to build the app bundle, and
resources.pbdescribe the code and resources in each module, which is useful when Google Play optimizes APKs for different device configurations.
- manifest/: Unlike APKs, app bundles store the
AndroidManifest.xmlfile of each module in this separate directory.
- dex/: Unlike APKs, app bundles store the DEX files for each module in this separate directory.
- res/, lib/, and assets/: These directories are identical to those in a typical APK. When you upload your app bundle, Google Play inspects these directories and packages only the files that satisfy the target device configuration, while preserving file paths.
root/: This directory stores files that are later relocated to the root of any APK that includes the module that this directory is located in. For example, the
base/root/directory of an app bundle may include Java-based resources that your app loads using
Class.getResource(). Those files are later relocated to the root directory of your app’s base APK and every multi-APK that Google Play generates. Paths within this directory are also preserved. That is, directories (and their subdirectories) are also relocated to the root of the APK.
Build and deploy Android App Bundles
An app bundle is different from an APK in that you can’t deploy one to a device. Rather, it’s a upload format that includes all your app’s compiled code and resources in a single build artifact. So, after you upload your signed app bundle, Google Play has everything it needs to build and sign your app’s APKs, and serve them to users through Dynamic Delivery.
If you’re using Android Studio, you can build your project as a signed app bundle in just a few clicks. If you're not using the IDE, you can instead build an app bundle from the command line. Then, simply upload your app bundle to the Play Console to test or publish your app with Dynamic Delivery.
Test your app bundle with bundletool
After you build your Android App Bundle, you should test how Google Play will use it to generate APKs and how those APKs will behave when deployed to a device.
You can perform these tests locally using
bundletool—the command line tool that
Gradle, Android Studio, and Google Play use to build an Android App Bundle or
convert an app bundle into APKs that are deployed to devices.
This tool is also useful for including app bundle support on your build server.
To learn how to download and use
Test Android App Bundles with bundletool.
After testing your app bundle locally, you should then test it through Google Play by uploading your app bundle to the Play Console. An internal test track allows you to upload an app bundle to the Play Console and start testing it on your device with Dynamic Delivery in just a few minutes.
Download dynamic feature modules with the Play Core Library
If your app includes dynamic features, it needs to use the Play Core Library to request, monitor, and manage dynamic feature module downloads. To learn more, go to Download modules with the Play Core Library.
If you want to see the library in action, try the Play Core Library sample app.
A note about Instant Apps
In Android Studio 3.2 or higher, you can add an instant experience to an app bundle, as long as your app's size is small enough. For details on the size limits for the different types of instant experiences that you can create, see Overview of Google Play Instant.
Compressed download size restriction
While publishing with Android App Bundles helps your users install your app with the smallest download possible, compressed downloads are limited to 150 MB. That is, when a user downloads your app, the total size of the compressed APKs required to install your app (for example, the base APK + configuration APK(s)) must be no more than 150 MB. Any subsequent downloads, such as downloading a dynamic feature (and its configuration APK(s)) on demand, must also meet this compressed download size restriction.
When you upload your app bundle, if the Play Console finds any of the possible downloads of your app or its on demand features to be more than 150 MB, you get an error.
Keep in mind, Android App Bundles do not support APK expansion (
files. So, if you encounter this error when publishing your app bundle, use
one of the following resources to reduce compressed APK download sizes:
- Make sure you
enable all configuration APKs
enableSplit = truefor each type of configuration APK. This makes sure that users download only the code and resources they need to run your app on their device.
- Make sure you shrink your app by removing unused code and resources.
- Follow best practices to further reduce app size.
- Consider converting features that are used by only some of your users into dynamic feature modules that your app can download later, on demand. Keep in mind, this may require some refactoring of your app, so make sure to first try the other suggestions described above.
The following are the currently known issues when building Android App Bundles or serving your app using Dynamic Delivery. If you experience issues that are not described below, please report a bug.
- If you use tools that dynamically modify resource tables, APKs generated from app bundles might behave unexpectedly. So, when building an app bundle, it is recommended that you disable such tools.
- In a dynamic feature module’s manifest, you should not reference resources that don’t exist in the base module. That’s because, when Google Play generates your app’s base APK, it merges manifests for all modules into that of the base APK. So, resource linking breaks if the base APK’s manifest references resources that don’t exist in the base APK.
- As of Android Studio 3.2 Canary 14, when you change the build variant for your app’s base module, the same build variant is not automatically selected for dynamic feature modules that depend on the base module. So, you might receive an error when building your app. Simply make sure that you select the same build variant for the base module and other modules that depend on it.
- It is currently possible to configure properties in a dynamic feature
module’s build configuration that conflict with those from the base (or
other) modules. For example, you can set
buildTypes.release.debuggable = truein the base module and set it to
falsein a dynamic feature module. Such conflicts might cause build and runtime issues. Keep in mind, by default, dynamic feature modules inherit some build configurations from the base module. So, make sure you understand which configurations you should keep, and which ones you should omit, in your Dynamic feature module build configuration.
- Because app installs may require downloading more than one APK (such the base APK and a few of its configuration APKs), you should be careful when manually transferring your app’s APKs onto a device (also known as sideloading). Otherwise, your app may experience runtime issues due to missing code and resources.
- Currently, Google Play includes all the code and resources for a dynamic feature module in a single APK. In the near future, for devices running Android 5.0 (API level 21) and higher, serving will be optimized to use configuration APKs.
- Downloading dynamic feature modules requires devices to have a recent version of the Play Store app installed. So, if your app includes dynamic feature modules, downloads for a very small percentage of users may fall back to a single optimized multi-APK, which is the same download experience for devices running Android 4.4 (API level 20) and lower.
To learn more about Android App Bundles, consult the following resources.
- PlayCore API sample, which demonstrates usage of the PlayCore API to request and download dynamic features.
- Dynamic code loading sample, which demonstrates three different approaches to safely access code from an installed dynamic feature module.
- Your First Android App Bundle,
a codelab that explores the basic principles of Android App Bundles and shows
you how to quickly get started with building your own using Android Studio.
This codelab also explores how to test your app bundles
- On demand modules, which helps you create an app that downloads and installs dynamic features on demand.
- What a new publishing format means for the future of Android
- New features to help you develop, release, and grow your business on Google Play
- The latest Android App Bundle updates including the additional languages API
- Patchwork Plaid — A modularization story
- Google Santa Tracker — Moving to an Android App Bundle