未设置 Ninja CMAKE_MAKE_PROGRAM 的 ndk 构建错误

问题描述:

我下载了 ndk cmake 和 LLDB 用于 ndk 开发.然后我创建了一个项目c++代码,应用程序编译错误.

I download ndk cmake and LLDB for ndk development.And then I create an project with c++ code,the application compiled error.

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.

...

Configuration failed.
External native generate JSON debug: JSON generation completed with problem
FAILURE: Build failed with an exception.

\* What went wrong:
Execution failed for task ':app:generateJsonModelDebug'.
com.android.ide.common.process.ProcessException: Error configuring

我通过 Valentin Safonnikov 的评论解决了这个问题:

I resolved the issue with Valentin Safonnikov's comment:

"您可以将 cmake 的路径添加到与 gradlew 相同的目录中的 local.properties 文件中,而不是更改全局路径.cmake.dir=D\:\\Android\\sdk\\cmake\\3.10.2.4988404"

"Instead changing global path, you can add the path to cmake into local.properties file in the same dir as gradlew. cmake.dir=D\:\\Android\\sdk\\cmake\\3.10.2.4988404"

我只认为它已解决.当我卸载 cmake 3.10 并只安装 cmake 3.6 时,所有问题才最终得到解决(即使使用 cmake.dir=...\\3.6...,它仍然使用 3.10.我可以在文本 gradle 输出:

I only thought it was solved. All issues were only finally solved when I uninstalled cmake 3.10 and left only cmake 3.6 installed (it kept using 3.10 even with cmake.dir=...\\3.6.... I could see this in the textual gradle output:

External native generate JSON debug: executing cmake Executable : C:\Users\User\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe
arguments : 
...
-DCMAKE_MAKE_PROGRAM=C:\Users\User\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe
...