完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

好久之前的一个Android项目,最近需要重构一下

因为Android Studio的开发环境以及Gradle的版本等等都进行了一定的更新,于是导入Project以后,出现了报错:

No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

如图所示:

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

显然这个错误是由于Android3.0(当然也可能是更高的版本)开发环境的版本更新所导致的


相关背景

NDK,是Native Development Kit的缩写,这是 Android的一个工具开发包,与java语言没有直接的关系

Native就是指C、C++这些语言

使用NDK可以快速开发C、C++的动态库,并自动将这些so文件与其他内容一起打包成APK

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

Android Studio环境下关于NDK的配置

先把目录切换为Project模式,点这个地方就行

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

然后选择local.properties文件,就是我标红的这个

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

可以看到这里记录了NDK和SDK在本地计算机上的存储路径

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android


进一步分析

首先打开SDK manager

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

出现以下界面

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

这里可以看到我的NDK是已经下载好的

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

那么这个下载好的NDK的路径在哪里呢,或者说这个下载好的NDK究竟放在哪里呢,我们查找一下

如下图操作,打开project structure

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

弹出如下界面

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

这里就是我们NDK的路径(位置了)

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

把这个路径复制一下,然后在我的电脑中打开,如图所示

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

打开这个目录下的toolchains文件夹

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

可以看到,这里确实没有IDE里报错说我们需要的那种库

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android


解决方法

打开如下链接,这是Android开发者的官方网站

https://developer.android.com/ndk/downloads/?hl=zh-cn

选择这个

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

点击下载

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

这个还是挺大的,需要等一会儿

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

下载完成后,解压缩,如图所示

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

打开这个目录下的toolchain文件夹,找到报错信息里你缺少的文件夹,比如我缺少的文件如下图所示

完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

把这个文件夹复制到NDK所在的路径即可

打开NDK所在路径的方法上面已经说过了

大功告成