android studio 用cmake编译报错

android studio错误信息:

Build command failed.
Error while executing process D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\bin\cmake.exe with arguments {-HF:\AndroidWorkSpace\**********\jni -BF:\AndroidWorkSpace\*******\.externalNativeBuild\cmake\debug\armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=F:\ndk\android-ndk-r9d -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=F:\AndroidWorkSpace\********\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\android.toolchain.cmake -DANDROID_PLATFORM=android-15 -DANDROID_PLATFORM=android-24 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static}
CMake Error at D:/Cpanfile/androidStudioSDK/cmake/3.6.4111459/android.toolchain.cmake:339 (message):
  Invalid Android platform: android-24.
Call Stack (most recent call first):
  D:/Cpanfile/androidStudioSDK/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (include)
  CMakeLists.txt
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Error:executing external native build for cmake F:\AndroidWorkSpace\****\jni\CMakeLists.txt
Build command failed.
Error while executing process D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\bin\cmake.exe with arguments {-HF:\AndroidWorkSpace\***********\jni -BF:\AndroidWorkSpace\********\.externalNativeBuild\cmake\release\armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=F:\ndk\android-ndk-r9d -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=F:\AndroidWorkSpace\*******\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=D:\Cpanfile\androidStudioSDK\cmake\3.6.4111459\android.toolchain.cmake -DANDROID_PLATFORM=android-15 -DANDROID_PLATFORM=android-24 -DANDROID_TOOLCHAIN=clang -DANDROID_STL=gnustl_static}
CMake Error at D:/Cpanfile/androidStudioSDK/cmake/3.6.4111459/android.toolchain.cmake:339 (message):
  Invalid Android platform: android-24.
Call Stack (most recent call first):
  D:/Cpanfile/androidStudioSDK/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (include)
  CMakeLists.txt
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Error:executing external native build for cmake F:\AndroidWorkSpace\*****\jni\CMakeLists.txt

解决方案:用新版的ndk,用新版cmake,更新android studio为3.0.1

看到有人在问更新了最新版为啥还不行,首先我当时的ndk和cmake的最新版不一定适用你现在的版本,这个错误原因有很多种,我这个只是其中一种原因,我当时这个问题主要就是ndk版本不对导致的,如果你们这个问题还没有解决,可以尝试更换多个ndk版本验证一下,也可以去ndk官网查看更新日志,说不定有帮助哦。

关注公众号 随时随地查看分享的文章哦,一起学习,一起进步

你可能感兴趣的:(移动开发,Android)