Android Bundletool Installation and Usage Guide

What is Bundletool?

Bundletool is Google’s official command-line tool for working with Android App Bundles (.aab files) and APKs. It allows developers to:

  • Convert App Bundles to APK sets
  • Generate APKs optimized for specific device configurations
  • Install APKs directly to connected devices
  • Extract information from App Bundles

Installation Guide

Prerequisites

  • Java 8 or higher installed on your system
  • Android device with USB debugging enabled (for installation)
  • Android Debug Bridge (ADB) installed and configured

Installing Bundletool

  1. Download the latest bundletool JAR file:

    curl -L https://github.com/google/bundletool/releases/download/1.18.1/bundletool-all-1.18.1.jar -o bundletool.jar

    Note: Check the GitHub releases page for the latest version.

  2. Make bundletool easier to use (optional but recommended):

    Create an alias in your shell profile (~/.zshrc or ~/.bash_profile):

    echo 'alias bundletool="java -jar $HOME/path/to/bundletool.jar"' >> ~/.zshrc
    source ~/.zshrc

    Alternatively, create a shell script:

    echo '#!/bin/bash
    java -jar $HOME/path/to/bundletool.jar "$@"' > /usr/local/bin/bundletool
    chmod +x /usr/local/bin/bundletool
  3. Verify installation:

    bundletool --help

    Or if you didn’t set up an alias:

    java -jar bundletool.jar --help

Using Bundletool to Install APKs

Method 1: Installing from an App Packages (.apks)

  1. Install the APK set to a connected device:

    bundletool install-apks --apks=YourApp.apks

    If you have multiple devices connected:

    bundletool install-apks --apks=YourApp.apks --device-id=device_serial_number

Troubleshooting

Common Issues

  1. “Command not found” error:

    • Ensure Java is installed and in your PATH
    • Check that the bundletool alias or script is correctly set up

Resources