- This post has 383 words.
- Estimated read time is 1.82 minute(s).
I was recently asked to describe the difference between the flutter build commands, "build apk" and "build apk --split-per-abi". If you've developed native Android apps for long, no doubt you already know the difference. But for those flocking to flutter and mobile development for the first time, it can be a bit confusing. So in this short post I'll explain.
Android (FAT) APKs are an archive file format that contain compiled code for multiple target architectures. The archive includes not only compiled code but things like resources (images, icons, audio files, etc...) as well. When apps started to get big, the option to split the APK into multiple archives, (one for each target architecture) was given as a way to reduce the install file size and download times. The command "flutter build apk" will build a "fat" archive, which includes all target architectures. The command "flutter build apk --split-per-abi" will build an archive of separated apks (one for each target architecture). If your app is very large or your users are in areas where they must pay for data, it is important to keep the APK size to a minimum. So it is recommended to use the " --split-per-abi" option.
You may wonder what "abi" is? It is an abbreviation for "Application Binary Interface" and each abi has its own architecture. Each architecture (CPU design) has it's own instruction set. Currently Android supports the following processor architectures:
|ABI||Supported Instruction Sets||Notes|
|armeabiThumb-2VFPv3-D16||Incompatible with ARMv5/v6 devices.|
|x86 (IA-32)MMXSSE/2/3SSSE3||No support for MOVBE or SSE4.|
Historically Android also supported ARMv5 (armeabi), and 32-bit and 64-bit MIPS, but support for these ABIs has been removed since NDK r17.
So which command should you use? Well, if your app is small and has few resources, you can choose to archive all versions of your app into a single large archive file using: flutter build apk However, if you app is medium to large in size or your uses are likely to need small downloads, or are in areas of poor network connections, then build an archive of one apk per abi using the command: flutter build apk --split-per-abi. Your users will thank you for it!