在使用 flutter build apk
构建 APK 文件时,请问什么版本的 Flutter 支持 --split-per-abi
选项。我正在使用 Flutter 1.5.4-hotfix.2
仍然无法访问该选项。
根据文档 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.
我怎样才能让它工作?
编辑:它适用于 Flutter 1.7.4
最佳答案
在您的<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
}
}
}
然后按照文档中的说明运行命令:
flutter build apk --split-per-abi
以下是支持的 ABI 列表: https://developer.android.com/ndk/guides/abis.html#sa
通过上面的配置,您应该获得所有受支持的 ABI
关于flutter - 找不到名为 "split-per-abi"的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56607075/