LinuxCommandLibrary

bundletool

Build Android App Bundles and APK sets

TLDR

Display help for a subcommand

$ bundletool help [subcommand]
copy

Generate APKs from an application bundle (prompts for keystore password)
$ bundletool build-apks --bundle [path/to/bundle.aab] --ks [path/to/key.keystore] --ks-key-alias [key_alias] --output [path/to/file.apks]
copy

Generate APKs from an application bundle giving the keystore password
$ bundletool build-apks --bundle [path/to/bundle.aab] --ks [path/to/key.keystore] --ks-key-alias [key_alias] --ks-pass [pass:the_password] --output [path/to/file.apks]
copy

Generate APKs including only one single APK for universal usage
$ bundletool build-apks --bundle [path/to/bundle.aab] --mode [universal] --ks [path/to/key.keystore] --ks-key-alias [key_alias] --output [path/to/file.apks]
copy

Install the right combination of APKs to an emulator or device
$ bundletool install-apks --apks [path/to/file.apks]
copy

Estimate the download size of an application
$ bundletool get-size total --apks [path/to/file.apks]
copy

Generate a device specification JSON file for an emulator or device
$ bundletool get-device-spec --output [path/to/file.json]
copy

Verify a bundle and display detailed information about it
$ bundletool validate --bundle [path/to/bundle.aab]
copy

SYNOPSIS

bundletool [options]

PARAMETERS

build-apks
    Builds an APK set from an Android App Bundle.

extract-apks
    Extracts APKs from an APK set.

get-size
    Gets the download size for a given device configuration.

validate
    Validates the App Bundle and lists potential issues.

print-asb
    Prints a JSON representation of an App Signing Bundle.

--bundle=
    Path to the input Android App Bundle.

--output=
    Path to the output APK set.

--config=
    Path to a JSON file describing the device configuration.

--connected-device
    Uses the configuration from the connected device to generate the apks.

--mode=
    Specify the mode. instant installs the instant app, while installed installs a regular app.

--modules=
    A comma-separated list of modules to extract from an APK set.

--ks=
    Path to the keystore file.

--ks-key-alias=
    Alias of the key to use from the keystore.

--ks-pass=
    Password for the keystore and key (if different).

--overwrite
    Overwrites the output file if it already exists.

--verbose
    Enables verbose logging.

--help
    Displays help information.

--version
    Displays the version of bundletool.

DESCRIPTION

bundletool is a command-line tool used by Android developers to build, test, and analyze Android App Bundles. An App Bundle is a publishing format that includes all your app’s compiled code and resources, and it defers APK generation and signing to Google Play. Bundletool allows you to create APK sets from bundles, test module delivery configurations locally, and inspect the contents of your App Bundles.

It is a key component in the process of generating optimized APKs for different device configurations, ultimately reducing app size and improving user experience. By using bundletool, developers can significantly reduce the size of their applications, leading to faster downloads and installation times for users, as well as more efficient storage utilization on user devices. Bundletool is particularly useful for complex applications with multiple features and a wide range of device compatibility requirements. It is maintained and updated by Google as part of the Android development ecosystem.

CAVEATS

Bundletool requires Java to be installed and configured correctly. Correct signing configurations are crucial for building valid APK sets.

APK SETS

APK Sets (.apks) are archive files containing multiple APKs optimized for different device configurations. They are not directly installable on devices and must be processed using bundletool to extract the appropriate APKs.

DEVICE CONFIGURATION SPECIFICATION

The device configuration specification is a JSON file that allows you to specify characteristics like the device's API level, screen density, and ABI architecture to generate the most appropriate APKs for it. This enables you to test how your app behaves on specific devices without needing to install it on actual hardware.

HISTORY

Bundletool was developed by Google to support the Android App Bundle format, which was introduced as a more efficient way to distribute Android applications. The development aimed to reduce application size by generating optimized APKs tailored to each device configuration. It has evolved over time with new features and improvements to support various Android features and deployment scenarios.

SEE ALSO

Copied to clipboard