CMake was unable to find a build program corresponding to "Ninja"解决方案

错误日志:


> Configure project :app
Support for CMake 3.7 and higher is a preview feature. To report a bug, see https://developer.android.com/studio/report-bugs.html
Support for CMake 3.7 and higher is a preview feature. To report a bug, see https://developer.android.com/studio/report-bugs.html
External native generate JSON debug: building json with force flag false
External native generate JSON debug: starting JSON generation
External native generate JSON debug: using platform version 24 for ABI ARMEABI_V7A and min SDK version 24
External native generate JSON debug: rebuilding JSON H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\debug\armeabi-v7a\android_gradle_build.json due to:
External native generate JSON debug: - command changed from previous, will remove stale json folder
External native generate JSON debug: removing stale contents from 'H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\debug\armeabi-v7a'
External native generate JSON debug: created folder 'H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\debug\armeabi-v7a'
External native generate JSON debug: executing cmake Executable : G:\Android_sdk_windows\cmake\3.10.2.4988404\bin\cmake.exe
arguments : 
-HH:\git.code\dn\ndk\ndk_pusher\app
-BH:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\debug\armeabi-v7a
-DANDROID_ABI=armeabi-v7a
-DANDROID_PLATFORM=android-24
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=H:\git.code\dn\ndk\ndk_pusher\app\build\intermediates\cmake\debug\obj\armeabi-v7a
-DCMAKE_BUILD_TYPE=Debug
-DANDROID_NDK=G:\Android_sdk_windows\ndk-bundle
-DCMAKE_CXX_FLAGS=
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a
-DCMAKE_SYSTEM_VERSION=24
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_ANDROID_NDK=G:\Android_sdk_windows\ndk-bundle
-DCMAKE_TOOLCHAIN_FILE=G:\Android_sdk_windows\ndk-bundle\build\cmake\android.toolchain.cmake
-G Ninja
jvmArgs : 


[== "CMake Server" ==[

{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{
  "type": "handshake",
  "cookie": "gradle-cmake-cookie",
  "protocolVersion": {
    "isExperimental": true,
    "major": 1,
    "minor": 1
  },
  "sourceDirectory": "H:/git.code/dn/ndk/ndk_pusher/app",
  "buildDirectory": "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/debug/armeabi-v7a",
  "generator": "Ninja"
}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"gradle-cmake-cookie","inReplyTo":"handshake","type":"reply"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{
  "type": "configure",
  "cacheArguments": [
    "",
    "-DANDROID_ABI\u003darmeabi-v7a",
    "-DANDROID_PLATFORM\u003dandroid-24",
    "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY\u003dH:\\git.code\\dn\\ndk\\ndk_pusher\\app\\build\\intermediates\\cmake\\debug\\obj\\armeabi-v7a",
    "-DCMAKE_BUILD_TYPE\u003dDebug",
    "-DANDROID_NDK\u003dG:\\Android_sdk_windows\\ndk-bundle",
    "-DCMAKE_CXX_FLAGS\u003d",
    "-DCMAKE_SYSTEM_NAME\u003dAndroid",
    "-DCMAKE_ANDROID_ARCH_ABI\u003darmeabi-v7a",
    "-DCMAKE_SYSTEM_VERSION\u003d24",
    "-DCMAKE_EXPORT_COMPILE_COMMANDS\u003dON",
    "-DCMAKE_ANDROID_NDK\u003dG:\\Android_sdk_windows\\ndk-bundle",
    "-DCMAKE_TOOLCHAIN_FILE\u003dG:\\Android_sdk_windows\\ndk-bundle\\build\\cmake\\android.toolchain.cmake",
    "-G Ninja"
  ]
}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"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.","title":"Error","type":"message"}

]== "CMake Server" ==]

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


[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","progressCurrent":1000,"progressMaximum":1000,"progressMessage":"Configuring","progressMinimum":0,"type":"progress"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"Configuring incomplete, errors occurred!\nSee also \"H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log\".","type":"message"}

]== "CMake Server" ==]

Configuring incomplete, errors occurred!
See also "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
Configuring incomplete, errors occurred!
See also "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".


[== "CMake Server" ==[

{"cookie":"","errorMessage":"Configuration failed.","inReplyTo":"configure","type":"error"}

]== "CMake Server" ==]

Configuration failed.
External native generate JSON debug: JSON generation completed with problems
External native generate JSON release: building json with force flag false
External native generate JSON release: starting JSON generation
External native generate JSON release: using platform version 24 for ABI ARMEABI_V7A and min SDK version 24
External native generate JSON release: rebuilding JSON H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a\android_gradle_build.json due to:
External native generate JSON release: - expected json H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a\android_gradle_build.json file is not present, will remove stale json folder
External native generate JSON release: - missing previous command file H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a\cmake_build_command.txt, will remove stale json folder
External native generate JSON release: removing stale contents from 'H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a'
External native generate JSON release: created folder 'H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a'
External native generate JSON release: executing cmake Executable : G:\Android_sdk_windows\cmake\3.10.2.4988404\bin\cmake.exe
arguments : 
-HH:\git.code\dn\ndk\ndk_pusher\app
-BH:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a
-DANDROID_ABI=armeabi-v7a
-DANDROID_PLATFORM=android-24
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=H:\git.code\dn\ndk\ndk_pusher\app\build\intermediates\cmake\release\obj\armeabi-v7a
-DCMAKE_BUILD_TYPE=Release
-DANDROID_NDK=G:\Android_sdk_windows\ndk-bundle
-DCMAKE_CXX_FLAGS=
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a
-DCMAKE_SYSTEM_VERSION=24
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_ANDROID_NDK=G:\Android_sdk_windows\ndk-bundle
-DCMAKE_TOOLCHAIN_FILE=G:\Android_sdk_windows\ndk-bundle\build\cmake\android.toolchain.cmake
-G Ninja
jvmArgs : 


[== "CMake Server" ==[

{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{
  "type": "handshake",
  "cookie": "gradle-cmake-cookie",
  "protocolVersion": {
    "isExperimental": true,
    "major": 1,
    "minor": 1
  },
  "sourceDirectory": "H:/git.code/dn/ndk/ndk_pusher/app",
  "buildDirectory": "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/release/armeabi-v7a",
  "generator": "Ninja"
}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"gradle-cmake-cookie","inReplyTo":"handshake","type":"reply"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{
  "type": "configure",
  "cacheArguments": [
    "",
    "-DANDROID_ABI\u003darmeabi-v7a",
    "-DANDROID_PLATFORM\u003dandroid-24",
    "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY\u003dH:\\git.code\\dn\\ndk\\ndk_pusher\\app\\build\\intermediates\\cmake\\release\\obj\\armeabi-v7a",
    "-DCMAKE_BUILD_TYPE\u003dRelease",
    "-DANDROID_NDK\u003dG:\\Android_sdk_windows\\ndk-bundle",
    "-DCMAKE_CXX_FLAGS\u003d",
    "-DCMAKE_SYSTEM_NAME\u003dAndroid",
    "-DCMAKE_ANDROID_ARCH_ABI\u003darmeabi-v7a",
    "-DCMAKE_SYSTEM_VERSION\u003d24",
    "-DCMAKE_EXPORT_COMPILE_COMMANDS\u003dON",
    "-DCMAKE_ANDROID_NDK\u003dG:\\Android_sdk_windows\\ndk-bundle",
    "-DCMAKE_TOOLCHAIN_FILE\u003dG:\\Android_sdk_windows\\ndk-bundle\\build\\cmake\\android.toolchain.cmake",
    "-G Ninja"
  ]
}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"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.","title":"Error","type":"message"}

]== "CMake Server" ==]

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


[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","progressCurrent":1000,"progressMaximum":1000,"progressMessage":"Configuring","progressMinimum":0,"type":"progress"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"Configuring incomplete, errors occurred!\nSee also \"H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log\".","type":"message"}

]== "CMake Server" ==]

Configuring incomplete, errors occurred!
See also "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
Configuring incomplete, errors occurred!
See also "H:/git.code/dn/ndk/ndk_pusher/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".


[== "CMake Server" ==[

{"cookie":"","errorMessage":"Configuration failed.","inReplyTo":"configure","type":"error"}

]== "CMake Server" ==]

Configuration failed.
External native generate JSON release: JSON generation completed with problems

CONFIGURE SUCCESSFUL in 46s
External native generate JSON debug: streaming 1 JSON files
External native generate JSON debug: streaming fallback JSON for H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\debug\armeabi-v7a\android_gradle_build.json
External native generate JSON release: streaming 1 JSON files
External native generate JSON release: streaming fallback JSON for H:\git.code\dn\ndk\ndk_pusher\app\.externalNativeBuild\cmake\release\armeabi-v7a\android_gradle_build.json
SIMPLE: Error configuring

红色部分为,错误提示和日志。我们可以看出找不到Ninja 相关环境。CMAKE_MAKE_PROGRAM 这没有设置。

解决方案为,修改工程 gradle版本。不低于3.3.0  

错误版本:
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
}

修改后:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
}

总结:

      此问题一般出现在升级android studio 和 相关插件是出现的。我是升级了NDK为19时出现的问题。

      主要是兼容新老版本问题。

 

 

 

你可能感兴趣的:(CMake was unable to find a build program corresponding to "Ninja"解决方案)