未设置Ninja的NDK构建错误CMAKE_MAKE_PROGRAM

时间:2019-02-13 09:20:06

标签: android-studio android-ndk

我下载了ndk cmake和LLDB进行ndk开发,然后用 c ++代码,应用程序编译错误。

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

2 个答案:

答案 0 :(得分:2)

我已经通过在路径中添加忍者来解决了这个问题。

/Users/fish/Library/Android/sdk/cmake/3.10.2.4988404/bin

答案 1 :(得分:0)

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

  

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

编辑:我只认为它已解决。当我卸载cmake 3.10并仅保留cmake 3.6时,所有问题都终于解决了(即使使用cmake.dir=...\\3.6...,它仍然使用3.10。我可以在文本gradle输出中看到这一点:

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
...