在用Android Studio 3.2.1导入以前的项目,进行编译的时候,报告如下错误信息:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
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'。
习惯于复制黏贴的懒人们,可以在下面复制代码:
|
1 |
def ndkWhich = new File(getNdkDirectory(),"ndk-which") |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// 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' } |

你这博客怎么搭建的?
标准的 WordPress