You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android CMake构建命令执行失败求助(NDK+Cmake新手)

Troubleshooting Your CMake/NDK Build Failure on Windows 10 x64

Hey there! As someone who's wrestled with plenty of Android NDK/CMake build headaches on Windows, let's break down what might be going wrong here and how to fix it. First, let's recap your failed build command for clarity:

Build command failed. Error while executing process E:\AndroidSdkWindows\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {
-HC:\Users\Fehoo\Desktop\Rentie\android\butterfly-streamer 
-BC:\Users\Fehoo\Desktop\Rentie\android\butterfly-streamer\.externalNativeBuild\cmake\debug\armeabi-v7a 
-DANDROID_ABI=armeabi-v7a 
-DANDROID_PLATFORM=android-21 
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Fehoo\Desktop\Rentie\android\butterfly-streamer\build\intermediates\cmake\debug\obj\armeabi-v7a 
-DCMAKE_BUILD_TYPE=Debug 
-DANDROID_NDK=C:\Users\Fehoo\sdk\ndk-bundle 
-DCMAKE_TOOLCHAIN_FILE=C:\Users\Fehoo\sdk\ndk-bundle\build\cmake\android.toolchain.cmake 
-DCMAKE_MAKE_PROGRAM=E:\AndroidSdkWindows\sdk\cmake\3.6.4111459\bin\ninja.exe 
-GAndroid Gradle - Ninja 
-DANDROID_STL=c++_static} 

(include) CMakeLists.txt -- Check for working C compiler: C:/Users/Fehoo/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe

Now here are the most likely fixes to try, in order:

  • Fix version compatibility issues
    Your CMake version (3.6.4111459) is pretty outdated, and modern ndk-bundle installations often require newer CMake versions. For example, NDK r21+ needs at least CMake 3.10.2. You have two options here:

    • Upgrade your CMake to a version that matches your NDK (check the NDK's built-in documentation or release notes for the minimum required CMake version)
    • Downgrade your NDK to a version compatible with CMake 3.6, like NDK r19c or earlier
  • Clean cached build files and rebuild
    Windows can be finicky with leftover build artifacts. Delete these two folders from your project:

    • .externalNativeBuild (the cached build folder referenced in your command)
    • The main build folder in your project directory
      Then sync your project with Gradle (click the "Sync Project with Gradle Files" button in Android Studio) and try building again.
  • Verify path correctness and avoid conflicts
    Double-check that all paths in your build command are valid:

    • Confirm C:\Users\Fehoo\sdk\ndk-bundle exists and has a complete, uncorrupted NDK installation
    • Make sure E:\AndroidSdkWindows\sdk\cmake\3.6.4111459 is a fully functional CMake setup
      Also, ensure none of your project or tool paths contain spaces or non-ASCII characters (your current paths look okay, but this is a super common Windows pitfall)
  • Simplify your CMakeLists.txt to isolate issues
    The error mentions checking for a working C compiler, which could mean your CMakeLists.txt has a basic configuration mistake. Try stripping it down to a minimal working example first:

    cmake_minimum_required(VERSION 3.6)
    project(butterfly-streamer)
    add_library(butterfly-streamer SHARED src/main/cpp/your-core-source.cpp)
    

    If this builds successfully, gradually add back your original configuration to pinpoint exactly where the problem occurs.

  • Confirm the Clang compiler is accessible
    Verify that the path C:/Users/Fehoo/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe exists. If it's missing, your NDK installation is probably corrupted—try re-downloading and reinstalling it.

内容的提问来源于stack exchange,提问作者Ahmed Fahmy

火山引擎 最新活动