热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AndroidCMake错误解决

前言这几天的任务是帮忙分析看看内存中的Bitmap的使用情况,同事推荐了腾讯Tencent的Matrix框架。【WIKI直通车】问题梳理与解决当我开心的将源码拉

前言

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


问题梳理与解决

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

(base) ➜ matrix-android git:(master) ✗ ./gradlew buildFAILURE: 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.orgBUILD 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

附录


  • Error:Error occurred while communicating with CMake server
  • Build failed at Cmake while building native module

推荐阅读
author-avatar
愛攝影的新胖
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有