Flutter 「Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the “Desktop development with C++” workload, and include these components:」の対処法

Flutter 「Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the “Desktop development with C++” workload, and include these components:」の対処法

「Flutter doctor」実行に、「Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the “Desktop development with C++” workload, and include these components:」が発生した場合の対処法を記述してます。

環境

  • OS  windows11 pro 64bit
  • Flutter 3.3.1

エラー全文

以下のコマンドを、実行時に発生。

> flutter doctor

[√] Flutter (Channel stable, 3.3.1, on Microsoft Windows [Version 10.0.22000.978], locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.70.1)
[√] Connected device (3 available)
[√] HTTP Host Availability

原因

「MSVC」がインストールされていないため

対処法

「Visual Studio Installer」から

「変更」をクリックして、

「C++によるデスクトップ開発」にチェックを入れて「変更」をクリックしてイントールを行います。

これでエラーは改善されます。

> flutter doctor

[√] Flutter (Channel stable, 3.3.1, on Microsoft Windows [Version 10.0.22000.978], locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.4)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.70.1)
[√] Connected device (3 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.