Sub topic 4
Shipping only what each device needs: split-per-ABI and app bundles
This chapter assumes you can build a Flutter app for Android from the command line, know the difference between debug, profile and release builds, and have already measured a release build with --analyze-size. You do not need to know Gradle in detail.
Why one APK is bigger than it needs to be
A Flutter Android app contains native code: the Flutter engine and your ahead-of-time (AOT) compiled Dart code. Native code is compiled for a specific CPU architecture, and Android calls these architectures ABIs (application binary interfaces). The ABIs Flutter targets on Android are:
| ABI | Typical devices |
|---|---|
| `arm64-v8a` | Almost all phones and tablets made in the last several years |
| `armeabi-v7a` | Older 32-bit ARM devices |
| `x86_64` | Emulators and some Chromebooks |
A "fat" APK contains the native libraries for every ABI. A device uses only one set, so the rest is dead weight in the download. In your size analysis, the lib/ folder (libflutter.so and libapp.so per ABI) usually shows up as the largest block. Removing the architectures a device cannot run is often the cheapest size reduction available, because it needs no code changes.
By default, flutter build apk in release mode builds a fat APK with the 32-bit ARM, 64-bit ARM and x86_64 libraries. Check the sizes on your own project instead of trusting a rule of thumb.
Option 1: one APK per ABI
The --split-per-abi flag tells the build to produce a separate APK for each architecture.
flutter build apk --split-per-abiThe output lands in build/app/outputs/flutter-apk/:
app-armeabi-v7a-release.apkapp-arm64-v8a-release.apkapp-x86_64-release.apk
Each file is smaller than the fat APK because it holds only one set of native libraries. Dart code, assets and resources are repeated in each file, so the sum of the three APKs is larger than the fat APK. That is expected. A user only downloads one.
You can also build a single architecture directly:
flutter build apk --target-platform android-arm64To see the effect, run the analysis from the earlier chapter on that single build:
flutter build apk --analyze-size --target-platform android-arm64Version codes
When you publish several APKs for one app, each needs a distinct version code, and a device must pick the right one. Flutter's Gradle plugin handles this when you use --split-per-abi: it adjusts the version code for each ABI so that stores can tell them apart. If you override versionCode in your Gradle files, check that the generated APKs still have distinct codes before uploading.
When split APKs make sense
- You distribute outside Google Play (your own website, an enterprise portal, or another store) and want smaller downloads.
- You sideload to test devices and want a quick, small file.
- You must give users a direct file link and cannot rely on a store to choose for them.
The cost is operational. You now manage several artifacts, and users who download the wrong one may get an app that does not install or run. Offer a clear naming scheme and tell users that arm64-v8a is the right choice for nearly all modern phones.
Option 2: Android App Bundles
An Android App Bundle (AAB) is a publishing format, not an installable file. You upload it to Google Play, and Play builds and signs APKs for each device configuration when users install.
flutter build appbundleThe result is build/app/outputs/bundle/release/app-release.aab.
From a bundle, Google Play generates split APKs. Play delivers a base APK plus configuration APKs for the device's ABI, screen density and language. This means a user also avoids downloading drawable densities and language resources their device does not use, not only the unused CPU architectures.
You can measure a bundle the same way as an APK:
flutter build appbundle --analyze-sizeNote that the size reported for a bundle is not the size a user downloads. The bundle contains everything for every device. The download size depends on which splits Play serves. The Play Console shows estimated download and install sizes per device configuration, and that is the number to track for store builds.
Google Play requirement
Google Play requires new apps to be published as app bundles. Check the current Play Console policy for your target date, since requirements change. In practice this makes the AAB your main artifact for Play, and --split-per-abi APKs a secondary artifact for other channels.
Comparing the three artifacts
| Artifact | Build command | Who picks the right parts | Best for |
|---|---|---|---|
| Fat APK | `flutter build apk` | Nobody, device ignores unused parts | Quick testing on unknown devices |
| Split APKs | `flutter build apk --split-per-abi` | You, by choosing which file to hand out | Direct distribution, other stores |
| App bundle | `flutter build appbundle` | Google Play at install time | Play Store releases |
Debug symbols and size
Native Flutter builds embed debug information in the compiled Dart library. Moving it to separate files shrinks the shipped binary. You do this with --split-debug-info, which writes symbol files to a directory you choose.
flutter build appbundle --obfuscate --split-debug-info=build/symbols--split-debug-info can be used on its own to reduce size. --obfuscate additionally renames identifiers and requires --split-debug-info. Obfuscation and symbol handling get their own chapter, so here you only need to remember two points that affect shipping:
- Keep the
build/symbolsdirectory for every release you ship. Without it you cannot turn stack traces from that release back into readable names. - Symbols belong to a specific build. Store them with the version number, not in a folder that the next build overwrites.
Edge cases and common errors
Testing the wrong file
A split APK built for arm64-v8a will not install on an armeabi-v7a-only device, and an x8664 APK will not run on a typical ARM phone. If an install fails with an ABI-related error such as `INSTALLFAILEDNOMATCHING_ABIS`, you used an APK that does not match the device. Check the device's supported ABIs:
adb shell getprop ro.product.cpu.abilist32-bit devices
If you drop armeabi-v7a to save space, devices that only support 32-bit code can no longer install your app. Check your analytics for the share of such devices before removing the target. Many apps still include it to avoid excluding users in some regions.
Measuring a debug build
Debug builds contain extra tooling, and their size and layout do not reflect what you ship. The earlier chapter on build modes explains why. Build in release mode, which is the default for flutter build apk and flutter build appbundle.
Comparing bundle size with APK size
An .aab file is often larger than any single APK from the same code, because it holds all configurations. Compare download sizes in the Play Console instead of comparing file sizes on disk.
Native code from packages
Packages that bundle their own native libraries also add per-ABI code. Splitting by ABI shrinks those too, but a package that ships many large libraries can still dominate the result. The dependency audit chapter covers finding them.
iOS
ABI splitting is Android-specific. On iOS, the App Store applies its own thinning (app slicing) when users install, and you do not control it with a Flutter flag. Use flutter build ipa --analyze-size to see what you ship, and remember that the store-reported download size will differ.
A practical workflow
- Build a fat APK with
--analyze-sizeand note the total and thelib/portion. - Build with
--split-per-abiand compare each APK to the fat one. - Build an app bundle for Play and record the estimated download size from the Play Console after upload to an internal test track.
- Store the symbols directory if you used
--split-debug-info. - Write down the numbers with the version, so later chapters on budgets have a baseline.
Summary of decisions
- Publishing to Google Play: build an app bundle.
- Distributing files yourself: use
--split-per-abiand document which file to pick. - Need one file that works everywhere, for example for a test group with unknown devices: use the fat APK and accept the size.
- Always keep the symbol files for each shipped build when using
--split-debug-info.
Exercise
Your team ships a release through Google Play and also posts an APK on its website. The Play listing shows a small download, but a user on the website complains the APK is very large. Which build commands would you use for each channel, and why?
Show answer
For Google Play, run flutter build appbundle and upload the .aab, so Play delivers a base APK plus the ABI, density and language splits each device needs. For the website, run flutter build apk --split-per-abi and publish the three APKs with clear names (for example pointing most users to the arm64-v8a file). The large APK the user saw was most likely the fat APK, which contains native libraries for every ABI.
Exercise
You build flutter build apk --split-per-abi and install app-x86_64-release.apk on a physical phone. The install fails with INSTALL_FAILED_NO_MATCHING_ABIS. What happened, and how do you find the right file?
Show answer
The phone uses an ARM processor, and the x86_64 APK contains no native libraries it can run. Run adb shell getprop ro.product.cpu.abilist to list the phone's supported ABIs, then install the APK that matches the first listed ABI, which is usually app-arm64-v8a-release.apk.