CMakeLists.txt 中的 CMake 错误:3(项目)找不到 Visual Studio 的指定实例

问题描述 投票:0回答:2

更改 Visual Studio 安装后,我无法运行我的 flutter windows 应用程序。运行 flutter windows 项目后出现此错误:

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
CMake Error at CMakeLists.txt:3 (project):
  Generator

    Visual Studio 17 2022

  could not find specified instance of Visual Studio:

    X:/Program Files/Microsoft Visual Studio/2022/Preview


Exception: Unable to generate build files

我有 Visual Studio 2022 预览版,但由于某种原因我删除了它,现在我安装了 Visual Studio 2022(不是预览版)。现在我无法再运行 flutter windows 项目了。

这是 flutter doctor 的输出,所有必需的组件均已安装:

[√] Flutter (Channel stable, 3.16.4, on Microsoft Windows [Version 10.0.19045.3803], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.8.4)
[√] Android Studio (version 2023.1)
[√] Connected device (3 available)
[√] Network resources
flutter
2个回答
2
投票

我可以解决这个问题:

  • 删除构建文件夹

  • 使缓存无效并重新启动

  • 最后在终端中运行

    flutter clean
    。然后运行项目。

我认为 flutter clean 就足够了,但我之前确实做了动作:)


0
投票

我也遇到同样的问题,执行完

flutter clean
后,重新执行就OK了

© www.soinside.com 2019 - 2024. All rights reserved.