Sub topic 4
Shipping only what each device needs: split-per-ABI and app bundles
Assume you already know how to run Flutter commands and have an Android release build configured. You should also understand that an Android device has a CPU architecture, called an ABI, and that Flutter apps may include native libraries for one or more ABIs.
Why one APK can be larger than necessary
An Android Package Kit (APK) is a file that can be installed directly on a device. A universal APK often contains native code for several ABIs, such as:
armeabi-v7afor older 32-bit ARM devicesarm64-v8afor current 64-bit ARM devicesx86_64for some emulators and specialized devices
A device uses only the native library that matches its ABI. The other copies still increase the download size of a universal APK.
A split-per-ABI build creates a separate APK for each supported ABI. Each APK contains only one ABI's native libraries. The files are smaller, but you must distribute the correct file or provide all relevant files through your release process.
| Distribution format | Who selects the ABI | Typical use |
|---|---|---|
| Split APKs | You or your distribution system | Direct downloads and some testing |
| Android App Bundle (`.aab`) | Google Play | Play Store releases |
| Universal APK | The package includes all selected ABIs | Simple sideloading or broad testing |
Build split APKs
Use a release build for meaningful size measurements. From the root of your Flutter project, run:
flutter build apk --release --split-per-abiFlutter writes ABI-specific files under build/app/outputs/flutter-apk/. Their names commonly include the ABI, such as app-armeabi-v7a-release.apk, app-arm64-v8a-release.apk, and app-x86_64-release.apk.
You can install the file that matches a connected device:
flutter install --release --use-application-binary=build/app/outputs/flutter-apk/app-arm64-v8a-release.apkCheck the device ABI before choosing a file. For an Android device connected through ADB, this command prints the primary ABI:
adb shell getprop ro.product.cpu.abiSplit APKs reduce the file you download, but they do not create one automatically updating package for every device. Your download page, testing service, or release pipeline must select the right artifact.
Build an Android App Bundle
An Android App Bundle is a publishing format with the .aab extension. Google Play uses the bundle to generate device-specific APKs. It can select the device's ABI and other configuration values when delivering the app.
Build one with:
flutter build appbundle --releaseThe resulting file is usually placed at:
build/app/outputs/bundle/release/app-release.aabYou upload the bundle to Google Play Console rather than installing it directly with adb. Google Play then creates optimized deliveries, so users generally do not download native libraries for ABIs their devices cannot run.
This arrangement gives you one release artifact while still avoiding unnecessary device-specific content. It also lets Google Play manage delivery variants as your supported ABIs change.
Choose the distribution method
The choice depends on where users obtain the application:
- Use an app bundle for normal Google Play distribution.
- Use split APKs for direct downloads, internal testing, or stores that expect APK files.
- Use a universal APK when installation simplicity matters more than download size, such as a controlled test environment.
Keep all supported ABIs in mind. Removing an ABI can make the app unavailable to devices that still require it. Before publishing, test at least one device or emulator for each ABI you intend to support.
Exercise
You need to publish through Google Play and want users to avoid downloading unused ABI libraries. Which Flutter command should you use, and why?
Show answer
Use flutter build appbundle --release. The Android App Bundle lets Google Play generate device-specific APKs and deliver the ABI needed by each device.