【嗨兴科技】Android Studio 3 在导入NDK工程的时候报"(include)CMakeLists.txt"构建错误解决方案

问题描述及截图:

问题发生场景:导入Android的NDK工程的时候,工程构建的时候报错:

External Native Build Issues
Build command failed.
Error while executing process D:\develop\android-sdk-windows\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Administrator\AndroidStudioProjects\HelloNDK\app -BC:\Users\Administrator\AndroidStudioProjects\HelloNDK\app\.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-19 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Administrator\AndroidStudioProjects\HelloNDK\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=D:\develop\android-sdk-windows\ndk-bundle -DCMAKE_CXX_FLAGS=-fexceptions -DCMAKE_TOOLCHAIN_FILE=D:\develop\android-sdk-windows\cmake\3.6.4111459\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=D:\develop\android-sdk-windows\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Build command failed.
Error while executing process D:\develop\android-sdk-windows\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Administrator\AndroidStudioProjects\HelloNDK\app -BC:\Users\Administrator\AndroidStudioProjects\HelloNDK\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-19 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Administrator\AndroidStudioProjects\HelloNDK\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=D:\develop\android-sdk-windows\ndk-bundle -DCMAKE_CXX_FLAGS=-fexceptions -DCMAKE_TOOLCHAIN_FILE=D:\develop\android-sdk-windows\cmake\3.6.4111459\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=D:\develop\android-sdk-windows\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

D:\develop\android-sdk-windows\cmake\3.6.4111459\android.toolchain.cmake
Error:(345, 98)  (include)   CMakeLists.txt 
Open File
Error:(345, 98)  (include)   CMakeLists.txt 
Open File

===========================================================================

具体的报错信息截图如下:

【嗨兴科技】Android Studio 3 在导入NDK工程的时候报


解决方案:

修改工程一级目录下的local.properties文件,把你电脑上正确的ndk.dir和sdk.die目录配置上,比如我的NDK和SDK安装目录如下:

ndk.dir=D\:\\develop\\android-ndk-r14b
sdk.dir=D\:\\develop\\android-sdk-windows

正确配置后的截图如下:

【嗨兴科技】Android Studio 3 在导入NDK工程的时候报

到此为止,该问题便可成功解决了!


最后,再来个工程构建成功后的截图:

【嗨兴科技】Android Studio 3 在导入NDK工程的时候报



你可能感兴趣的:(Android编程)