在使用--split-per-abi
构建APK文件时,请哪种版本的flutter支持flutter build apk
选项。我正在使用Flutter 1.5.4-hotfix.2
,但仍然无法访问该选项。
根据{{3}}文档,
此命令产生两个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
删除--split-per-abi标志会导致包含以下内容的胖APK 您为所有目标ABI编译的代码。这样的APK在 大小超过拆分后的对应内容,导致用户下载 不适用于其设备的本机二进制文件 建筑。
我如何使其工作?
编辑:它适用于Flutter 1.7.4
答案 0 :(得分: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