Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find an option named "split-per-abi"

Tags:

apk

flutter

dart

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

like image 582
nonybrighto Avatar asked Jun 15 '19 03:06

nonybrighto


People also ask

What is -- Split per ABI?

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.

What is the ABI in flutter?

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.


1 Answers

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

enter image description here

like image 180
davidcv5 Avatar answered Oct 22 '22 07:10

davidcv5