Android CMake错误解决

前言

这几天的任务是帮忙分析看看内存中的Bitmap的使用情况,同事推荐了腾讯Tencent的Matrix框架【WIKI直通车】

问题梳理与解决

当我开心的将源码拉下来编译./gradlew build的时候,Android Studio给我来了一波错误的洗礼!!!╮(╯▽╰)╭

(base) ➜  matrix-android git:(master) ✗ ./gradlew build

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':matrix-android-commons'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

这个问题比较明显,是因为我现在安装的这个版本19toolchains中没有了mips64el-linux-android这个东西啦。

在NDK 18的更新记录里有一段话:

This version of the NDK is incompatible with the Android Gradle plugin version 3.0 or older. If you see an error like No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android, update your project file to [use plugin version 3.1 or newer]. You will also need to upgrade to Android Studio 3.1 or newer.

因此,当我们不想要升级Gradle版本的时候,有且仅有的办法就是修改NDK的版本。【历史版本NDK】

下载完毕之后,在项目根目录的local.properties中修改ndk.dir的路径为/home/notzuonotdied/Android/NDK/android-ndk-r16b即可。

修改完毕,继续./gradlew build --stacktrace一下试试看看。

> Task :matrix-io-canary:generateJsonModelDebug


[== "CMake Server" ==[

{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

]== "CMake Server" ==]



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':matrix-io-canary:generateJsonModelDebug'.
> Error occurred while communicating with CMake server. Check log /home/notzuonotdied/Android/Project/matrix/matrix/matrix-android/matrix-io-canary/.externalNativeBuild/cmake/debug/armeabi-v7a/cmake_server_log.txt for additional information.

有出错了,好吧,我们顺便看看文件里面有啥~

➜  ~ cat /home/notzuonotdied/Android/Project/matrix/matrix/matrix-android/matrix-io-canary/.externalNativeBuild/cmake/debug/armeabi-v7a/cmake_server_log.txt 
CMAKE SERVER: 

CMAKE SERVER: [== "CMake Server" ==[

CMAKE SERVER: {"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

CMAKE SERVER: ]== "CMake Server" ==]

居然就是我们前面Log输出的内容,这就有点尴尬了。只能Google下了。在Error:Error occurred while communicating with CMake server,中指出来了CMake is 3.10xxx is not working on my machine, CMake 3.6.4111459 is on working machine.Replaced these three items, the project is built successfully on my machine.

所以,罪魁祸首就是我们Android Studio中帮我们装了高版本的CMake,我们仅仅需要3.6版本的CMake。

流程:SDK Manager --> Android SDK --> SDK Tools --> 卸载CMake 3.10版本

在这里插入图片描述
当我们没有勾选下面的Show Package Detail的时候,就会默认两个一起安装,我们需要卸载3.10这个版本的CMake。
在这里插入图片描述删除:
在这里插入图片描述

我们重新试试!

# 编译成功
BUILD SUCCESSFUL in 13s
440 actionable tasks: 10 executed, 430 up-to-date

附录

发布了181 篇原创文章 · 获赞 217 · 访问量 45万+

猜你喜欢

转载自blog.csdn.net/Notzuonotdied/article/details/89501285
今日推荐