flutterのインストール後、環境チェックのflutter doctor
を実行した際に、以下のメッセージが表示されたときの解決方法
cmdline-tools component is missing
Flutter requires Android SDK 29 and the Android BuildTools 28.0.3
Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
手順
flutterのインストール後、 flutter doctor
を実行すると、以下となった
PS C:\src\flutter> flutter doctor ╔════════════════════════════════════════════════════════════════════════════╗ ║ Welcome to Flutter! - https://flutter.dev ║ ║ ║ ║ The Flutter tool uses Google Analytics to anonymously report feature usage ║ ║ statistics and basic crash reports. This data is used to help improve ║ ║ Flutter tools over time. ║ ║ ║ ║ Flutter tool analytics are not sent on the very first run. To disable ║ ║ reporting, type 'flutter config --no-analytics'. To display the current ║ ║ setting, type 'flutter config'. If you opt out of analytics, an opt-out ║ ║ event will be sent, and then no further information will be sent by the ║ ║ Flutter tool. ║ ║ ║ ║ By downloading the Flutter SDK, you agree to the Google Terms of Service. ║ ║ Note: The Google Privacy Policy describes how data is handled in this ║ ║ service. ║ ║ ║ ║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and ║ ║ crash reports to Google. ║ ║ ║ ║ Read about data we send with crash reports: ║ ║ https://flutter.dev/docs/reference/crash-reporting ║ ║ ║ ║ See Google's privacy policy: ║ ║ https://policies.google.com/privacy ║ ╚════════════════════════════════════════════════════════════════════════════╝ Running "flutter pub get" in flutter_tools... 8.8s Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1645], locale ja-JP) [✗] Android toolchain - develop for Android devices ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. [✓] Chrome - develop for the web [✗] Visual Studio - develop for Windows ✗ Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [!] Android Studio (not installed) [✓] VS Code [✓] VS Code, 64-bit edition (version 1.66.0) [✓] Connected device (3 available) [✓] HTTP Host Availability ! Doctor found issues in 3 categories.
インストールされていないAndroid StudioとVisual Studioの最新版をインストールして再実行したところ、以下のエラーが残った
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
cmdline-tools componentがないようなので追加する
Android Studioを起動する
More Actionを選択する
SDK Managerを選択する
Appearance & Behavior → System Settings → Android SDK → SDK Tools の一覧から、Android SDK Command-line Tools (latest)にチェックを付けてOKを押すと、追加インストールされる。
flutter doctor
を再実行すると、以下のエラーとなった
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) ✗ Flutter requires Android SDK 29 and the Android BuildTools 28.0.3 To update the Android SDK visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions. ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
SDK 29が要求されたので、Android StudioのSDK Managerから、同様にインストールする。 SDK 29の数字はAPI Levelなので、Android 10.0を選択する。
[!] Android toolchain - develop for Android devices (Android SDK version 32.0.0) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
については、flutter doctor --android-licenses
を実行し、すべてAccept? (y/N): yと入力する。
すべてのエラーがなくなった。
PS C:\src\flutter> flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1645], locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) [✓] Chrome - develop for the web [✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6) [✓] Android Studio (version 2021.1) [✓] VS Code [✓] VS Code, 64-bit edition (version 1.66.0) [✓] Connected device (3 available) [✓] HTTP Host Availability • No issues found!