What is the difference between 3 APKs generated from flutter?
Solution 1
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.
Solution 2
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
Solution 3
Run flutter build apk --split-per-abi
This command results in three APK files:
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
<app dir>/build/app/outputs/apk/release/app-x86_64-release.apk
Removing the --split-per-abi
flag 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.
ABI means : Application Binary Interface
APK means : Android Package
app dir is your application’s directory
NOTE : If you can build an app bundle instead of apk , do it .With this, the application will be signed more easily .
By default, the app bundle contains your Dart code and the Flutter runtime compiled for armeabi-v7a (ARM 32-bit), arm64-v8a (ARM 64-bit), and x86-64 (x86 64-bit)
.
Abdurrahman Anas
Updated on December 16, 2022Comments
-
Abdurrahman Anas over 1 year
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.
-
TheNoobDeveloper0299 about 4 yearsoutputs>flutter-apk>app-release.apk and output>apk>release>app-release.apk are the same files ?
-
encubos almost 4 years@TheNoobDeveloper0299, yes. Newer flutter versions use the "flutter-apk" path. The old path is kept for compatibility