找不到名为“ split-per-abi”的选项

non*_*hto 6 apk dart flutter

--split-per-abi使用生成APK文件时,请哪种版本的flutter支持该选项flutter build apk。我正在使用,Flutter 1.5.4-hotfix.2但仍然无法访问该选项。
根据文档“ 准备发布Android应用”

此命令产生两个APK文件:

<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
Run Code Online (Sandbox Code Playgroud)

删除--split-per-abi标志会生成一个胖APK,其中包含为所有目标ABI编译的代码。此类APK的大小要大于拆分后的对应APK,从而导致用户下载不适用于其设备架构的本机二进制文件。

我该如何运作?

编辑:它适用于Flutter 1.7.4

dav*_*cv5 7

在您<app dir>/android/app/build.gradle添加的splits部分中,如此处所述:https : //developer.android.com/studio/build/configure-apk-splits#configure-abi-split

基本配置是将其添加到您的 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
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

然后按照文档所述运行命令:

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
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

以下是受支持的ABI的列表:https : //developer.android.com/ndk/guides/abis.html#sa

通过上面的配置,您应该获得所有受支持的ABI

在此处输入图片说明

  • 啊! 非常感谢!我尝试了带有标志的配置,它仍然给出相同的错误,但是使用您提供的配置运行`flutter build apk`仍然会生成各种体系结构的APK。 (2认同)