Android Studio 3.2.1解决错误信息"ABIs [armeabi] are not supported for platform. Supported A...

栏目: IOS · Android · 发布时间: 7年前

内容简介:在用问题发生的原因在于以前的代码在虽然可以简单的修改成

在用 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'

具体的操作如下图所示:

Android Studio 3.2.1解决错误信息

习惯于复制黏贴的懒人们,可以在下面复制代码:

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'
}

参考链接


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

深入理解程序设计

深入理解程序设计

[美] Jonathan Bartlett / 郭晴霞 / 人民邮电出版社 / 2014-1 / 49.00

是否真正理解汇编语言,常常是普通程序员和优秀程序员的分水岭。《深入理解程序设计:使用Linux汇编语言》介绍了Linux平台下的汇编语言编程,教你从计算机的角度看问题,从而了解汇编语言及计算机的工作方式,为成就自己的优秀程序员之梦夯实基础。 很多人都认为汇编语言晦涩难懂,但New Medio技术总监Jonathan Bartlett的这本书将改变人们的看法。本书首先介绍计算机的体系结构,然后......一起来看看 《深入理解程序设计》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具