内容简介:在用问题发生的原因在于以前的代码在虽然可以简单的修改成
在用 Android Studio 3.2.1 导入以前的项目,进行编译的时候,报告如下错误信息:
FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':app'. > ABIs [armeabi] are not supported for platform. Supported ABIs are [arm64-v8a, armeabi-v7a, x86, x86_64]. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 0s
问题发生的原因在于以前的代码在 build.gradle 中指定了 abiFilters 'armeabi' ,但是从 NDK r17 版本开始,已经不支持 "armeabi、mips、mips64" 这三种 ABI 了。
虽然可以简单的修改成 abiFilters 'armeabi-v7a' ,来解决问题,但是我们更希望能有一个办法,在老版本的支持 abiFilters 'armeabi' 的 NDK 上继续使用 abiFilters 'armeabi' 进行编译,用来兼容老设备。而在只支持 abiFilters 'armeabi-v7a' 的设备上,我们使用 abiFilters 'armeabi-v7a' 保证能编译通过。
我们通过执行 NDK 目录下的 ndk-which 输出的支持的 ABI 列表的方式获取当前的 NDK 是否支持 abiFilters 'armeabi' ,如果不支持,我们就设置为 abiFilters 'armeabi-v7a' 。
具体的操作如下图所示:
习惯于复制黏贴的懒人们,可以在下面复制代码:
def ndkWhich = new File(getNdkDirectory(),"ndk-which")
// from NDK r17 "armeabi、mips、mips64" not supported
try {
def ndkWhichExec = ndkWhich.toString().execute() //ndk-which not exists cause exception
def abiOutput = new ByteArrayOutputStream()
ndkWhichExec.waitForProcessOutput(abiOutput, null)
abiOutput = abiOutput.toString().toUpperCase()
if (abiOutput.contains('USAGE:') && abiOutput.contains("ABI")) {
if (abiOutput.contains("'armeabi'")) {
abiFilters 'armeabi'
} else {
abiFilters 'armeabi-v7a'
}
} else {
abiFilters 'armeabi'
}
} catch (Exception e) {
abiFilters 'armeabi'
}
参考链接
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Node.js实战
[美] Mike Cantelon、[美] TJ Holowaychuk、[美] Nathan Rajlich / 吴海星 / 人民邮电出版社 / 2014-5 / 69.00元
服务器端JavaScript?没错。Node.js是一个JavaScript服务器,支持可伸缩的高性能Web应用。借助异步I/O,这个服务器可以同时做很多事情,能满足聊天、游戏和实时统计等应用的需求。并且既然是JavaScript,那你就可以全栈使用一种语言。 本书向读者展示了如何构建产品级应用,对关键概念的介绍清晰明了,贴近实际的例子,涵盖从安装到部署的各个环节,是一部讲解与实践并重的优秀......一起来看看 《Node.js实战》 这本书的介绍吧!