Please what version of flutter support the --split-per-abi
option when building an APK file with flutter build apk
. I am making use of Flutter 1.5.4-hotfix.2
and still can't access that option.
According to the documentation Preparing an Android app for release,
This command results in two 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
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.
How can I make it work?
EDIT: It works on Flutter 1.7.4
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.
An application binary interface (ABI). An ABI defines the memory layout of data and the function call protocol for native code. It is usually defined by the an operating system for each architecture that operating system runs on. The Dart VM can run on a variety of operating systems and architectures.
In your <app dir>/android/app/build.gradle
add a splits
section as described here: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
A basic configuration would be to add this to your build.gradle
android {
...
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
}
Then just run the command as the documentation says:
flutter build apk --split-per-abi
Here is the list of supported ABIs: https://developer.android.com/ndk/guides/abis.html#sa
With the config above you should get all supported ABIs
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