8

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
shizhen
  • 12,251
  • 9
  • 52
  • 88
chefish
  • 517
  • 2
  • 7
  • 20
  • You downloaded CMake with the SDK Manager right? Not from some other place. I have three cmake versions in my Android SDK directory, and all of them contain `ninja.exe` in their `bin` subdirectory. – Michael Feb 13 '19 at 10:18
  • I downloaded CMake by Android studio.There is ninja in the directory /Users/fish/Library/Android/sdk/cmake/3.10.2.4988404/bin – chefish Feb 13 '19 at 10:36
  • Check similar issue discussed here [Android Studio CMake/Ninja Not Used for Building an NDK project](https://stackoverflow.com/a/54473346/8034839) – shizhen Feb 14 '19 at 01:55

2 Answers2

8

I resolved the issue with Valentin Safonnikov's comment:

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

Edit: 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
...
Aur Saraf
  • 3,214
  • 1
  • 26
  • 15
3

I have solve the problem by add ninja to Path.

/Users/fish/Library/Android/sdk/cmake/3.10.2.4988404/bin
chefish
  • 517
  • 2
  • 7
  • 20
  • 1
    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` – Valentin Safonnikov Apr 03 '19 at 07:31
  • @chefish What does it mean "add ninja to Path" ? Where can I find this 'Path'? Thanks – toto_tata Jun 28 '21 at 11:23