You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter编译Windows应用提示需CMake 3.23+,但本地已装3.28仍报错

Flutter Windows编译CMake版本不匹配问题解决

问题详情

  • 运行flutter run选择Windows设备后编译报错,提示symlinks/record_windows/windows/CMakeLists.txt要求CMake版本至少为3.23,但编译时实际使用的版本是3.20.21032501-MSVC_2
  • 本地通过cmake --version查询已安装3.28.1版本
  • 已尝试flutter clean、重新安装CMake,问题仍未解决
  • Flutter Doctor检测结果:
Doctor summary (to see all details, run
flutter doctor -v):
[√] Flutter (Channel stable, 3.16.5, on
    Microsoft Windows [versÆo
    10.0.19045.3992], locale pt-BR)      
[√] Windows Version (Installed version of Windows is version 10 or higher)     
[X] Android toolchain - develop for      
    Android devices
    X Unable to locate Android SDK.      
      Install Android Studio from:       
      https://developer.android.com/studio/index.html
      On first launch it will assist you 
      in installing the Android SDK      
      components.
      (or visit
      https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been        
      installed to a custom location,    
      please use
      `flutter config --android-sdk` to  
      update to that location.

[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps
    (Visual Studio Community 2019        
    16.11.32)
[!] Android Studio (not installed)       
[√] VS Code (version 1.85.1)
[√] Connected device (3 available)
[√] Network resources

解决方案

  • 更新Visual Studio内置CMake
    打开Visual Studio Installer,找到已安装的Visual Studio Community 2019,点击「修改」,在「单个组件」中搜索「CMake」,勾选安装版本≥3.23的CMake组件,完成安装后重启VS。

  • 指定Flutter使用全局CMake
    执行命令强制Flutter调用你安装的3.28.1版本CMake:

    flutter config --cmake-dir "C:\Program Files\CMake\bin"
    

    路径根据你的实际安装位置调整。

  • 调整环境变量优先级
    右键「此电脑」→「属性」→「高级系统设置」→「环境变量」,在系统变量的Path中,将C:\Program Files\CMake\bin移到Visual Studio内置CMake路径的上方,保存后重启终端和IDE再尝试编译。

  • 降低record_windows插件版本
    打开pubspec.yaml,找到record或record_windows依赖项,指定一个CMake要求≤3.20的历史版本,执行flutter pub get后重新编译。

内容的提问来源于stack exchange,提问作者Leonardo kop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 07:20:01