文章目录
一、报错信息
二、解决方案
1、方案一
2、方案二
一、报错信息
重装系统后 , 打开一年前的项目 , 报如下错误 :
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.498840
2、方案二
点击 " Download " 按钮 , 下载最新 NDK ;