I need to understand the Android device architecture and, Why there is three different types of APKs are generated when I use:
flutter build apk --split-per-abi
.
And when I use
flutter build apk
I get a large APK file called fat APK contains the 3 versions of the app.
APK (Application Package File) is a format used by Android operating systems for distribution and installation. After you build an application, it's quite common to build APK files to be tested across different devices.
Why does the first Flutter app build take so long? When building a Flutter app for the first time, a device-specific APK or IPA file is built. Hence, Gradle and XCode are used to build the files, taking time.
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.
The command flutter build apk --split-per-abi
typically generates two APK files.
arm64
or x86_64 is the apk file for devices having 64-bit processors.x86
is the apk file for 32-bit processors.You can upload both of them on the PlayStore and based on the user's device architecture the corresponding apk will be installed.
The fat apk that you are getting while using the flutter build apk
contains the necessary compiled code to target all the Application Binary Interfaces or ABIs. Once a user downloads this fat apk, then only the code applicable to the device will be used.
flutter build apk
gives you large apk because,
flutter build apk
results in a fat APK that contains your code compiled for all the target ABIs. Such APKs are larger in size than their split counterparts, causing the user to download native binaries that are not applicable to their device’s architecture.
--split-per-abi
results in two APK files:
(The flutter build command defaults to --release.)
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
Where armeabi-v7a for is 32-bit devices and arm64-v8a for 64-bit devices.
Read More on
https://flutter.dev/docs/deployment/android#build-an-apk
https://flutter.dev/docs/deployment/android#build-an-app-bundle
https://developer.android.com/studio/build/configure-apk-splits#configure-split
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With