android - 如何为 armv8 编译本机库?
问题描述
我正在为四种架构 x86、x86_64、armeabi-v7a 和 arm64-v8a 编译拆分 apk。该应用程序运行良好,并且可以在大多数设备上正常加载本机库。但在某些设备上,出现无法在 armv8 文件夹或 arm 文件夹中找到 mylibrary.so .in 的错误。这是我生成拆分 apk 并生成不满意链接错误的代码
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, armeabi-v7a, and mips.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
// Specifies that we want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
def abiCodes = ['x86':0, 'x86_64':1, 'armeabi-v7a':2, 'arm64-v8a':3]
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
variant.outputs.each {
output ->
def abiName = output.getFilter(OutputFile.ABI)
output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
}
}
当我分析 apk 时,我成功地在 libs 文件夹和所有其他 apk 的 libs 文件夹中的 arm64-v8a apk 中获得所需的本机库。
解决方案
推荐阅读
- android - Android SQLITE:根据列值获取 Id 值
- linux - nginx:Docker 上的 [emerg] socket() 0.0.0.0:80 失败(13:权限被拒绝)
- tensorflow - 水平平移张量,用零回填
- python - 生成所有给定限制的矩阵
- python - 如何使用sql数据库中的列值作为python函数的参数?
- apache-spark - 在 Spark SQL 中“展平”数据帧时出现 Spark AnalysisException
- ember.js - 我正在尝试从 ember 1.7 升级到 1.13
- css - 当元素 y 具有绝对位置时,为什么下面的元素 x 到另一个元素 y 向上移动
- android - 单独片段的搜索栏
- php - 如何使用此插图实现服务器到服务器的数据