错误记录NDK 配置错误 ( C/C++ debug|arm64-v8a : Could not get version from cmake.dir path )

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录NDK 配置错误 ( C/C++ debug|arm64-v8a : Could not get version from cmake.dir path )相关的知识,希望对你有一定的参考价值。





一、报错信息



重装系统后 , 打开一年前的项目 , 报如下错误 :

CMakeLists.txt : C/C++ debug|arm64-v8a : Could not get version from cmake.dir path 'D:\\001_Programs\\001_android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.

完整报错信息 :

Executing tasks: [:app:assembleDebug] in project D:\\002_Project\\Application


> Configure project :app
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :sample9_4:preBuild UP-TO-DATE
> Task :sample9_4:preDebugBuild UP-TO-DATE
> Task :sample9_4:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :sample9_4:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :sample9_4:compileDebugRenderscript NO-SOURCE
> Task :sample9_4:generateDebugResValues
> Task :sample9_4:generateDebugResources
> Task :sample9_4:packageDebugResources
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
> Task :app:createDebugCompatibleScreenManifests
> Task :app:extractDeepLinksDebug
> Task :sample9_4:extractDeepLinksDebug
> Task :sample9_4:writeDebugAarMetadata
> Task :sample9_4:generateDebugBuildConfig

> Task :app:generateJsonModelDebug FAILED
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.
Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.

> Task :sample9_4:javaPreCompileDebug
> Task :app:javaPreCompileDebug
> Task :sample9_4:processDebugManifest
> Task :sample9_4:parseDebugLocalResources
> Task :app:checkDebugAarMetadata
> Task :sample9_4:compileDebugLibraryResources
> Task :app:mergeDebugResources

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateJsonModelDebug'.
> D:\\002_Project\\Application\\app\\src\\main\\cpp\\CMakeLists.txt : C/C++ debug|arm64-v8a : Could not get version from cmake.dir path 'D:\\001_Programs\\001_Android\\002_Sdk\\Sdk\\cmake\\3.10.2.4988404'.

* 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 4s
17 actionable tasks: 17 executed

在这里插入图片描述





二、解决方案



出现这种问题是因为 NDK 目录配置错误 , 要么之前的配置没有删除干净 , 要么电脑上的 SDK 中没有安装 NDK ;


1、方案一


打开 local.properties 文件 , 发现有如下配置 , 直接删除 cmake.dir 配置 ;

sdk.dir=D\\:\\\\001_Develop\\\\001_SDK\\\\Sdk
cmake.dir=D\\:\\\\001_Programs\\\\001_Android\\\\002_Sdk\\\\Sdk\\\\cmake\\\\3.10.2.4988404

在这里插入图片描述


2、方案二


在这里插入图片描述

点击 " Download " 按钮 , 下载最新 NDK ;

在这里插入图片描述

以上是关于错误记录NDK 配置错误 ( C/C++ debug|arm64-v8a : Could not get version from cmake.dir path )的主要内容,如果未能解决你的问题,请参考以下文章

如何定位Android NDK开发中遇到的错误

错误记录Visual Studio 中配置 NDK 头文件路径 ( NDK 的三个头文件路径 | 与 CPU 架构相关 asm 头文件路径选择 )

如何定位Android NDK开发中遇到的错误

我的C/C++语言学习进阶之旅NDK开发之解决错误:signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0xXXX

我的C/C++语言学习进阶之旅NDK开发之解决错误:signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0xXXX

我的Android进阶之旅Android Studio的NDK项目可以运行,但是C++代码全部报红的错误