Android App Bundles
Last modified on Tue 09 Mar 2021

An Android App Bundle is a new upload format with the .aab file extension. A bundle will include all your app’s compiled code and resources, so you can upload it to Google Play just as a regular APK file. Google Play generates and signs an optimized APK for each user’s device configuration out of the uploaded bundle.

Prepare

Before you start building a bundle make sure that you can and/or are allowed to enable app signing by Google Play.
Check how to opt-in here.
Otherwise, you can't upload your app bundle to the Play Console.

Configure bundle in your Gradle build script by enabling or disabling language, density and architecture split parameters.
It is recommended to disable language split when your support language switching while application is running.
If enabled, split will remove all but default and current device language from the bundle and break runtime language switch.

android {

    ...

    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = true
        }
        abi {
            enableSplit = true
        }
    }
}

Preferably, edit module configurations to create a bundle when running an application instead a default APK.
Edit configurations

Build

Easiest way to create a bundle is to use Android Studio 3.2 or higher.
Bundle can be built via UI, from Build menu, or CLI, just like assembleSomeFlavor tasks use a bundleSomeFlavor task.

Upload

Upload your app bundle to the Play Console just like a normal APK as before.

Good to know