Solving Flutter error: cmdline-tools component is missing

Updated: December 11, 2023 By: Khue Post a comment

The Flutter error cmdline-tools component is missing occurs when the Android SDK Command-line Tools are not installed or configured properly. This can prevent Flutter from detecting and using the Android SDK and toolchain. To fix this error, you need to install and update the Android SDK Command-line Tools and make sure they are added to your PATH environment variable.

This concise, straight-to-the-point article will walk you through some different approaches to get rid of the mentioned problem.

Using Android Studio

This solution involves using the Android Studio IDE to install the Android SDK Command-line Tools from the SDK Manager. This is the easiest and recommended way to install the tools, as Android Studio will handle the installation and configuration for you.

The steps:

1. Open Android Studio and click on More Actions on the welcome screen. Next, click on SDK Manager.

2. In the Preferences window, go to the SDK Tools tab, then check the box next to Android SDK Command-line Tools (latest).

3. Click Apply and then OK. It will download and install the tools for you.

4. Restart Android Studio and run flutter doctor to check if the error is successfully fixed.

This solution is simple, fast, and reliable. It does not require any manual configuration or editing of environment variables. It ensures that the tools are compatible with the Android SDK and Android Studio.

Using Command Line

This solution involves using the sdkmanager command-line tool to install the Android SDK Command-line Tools from the terminal or command prompt. This is an alternative way to install the tools, especially if prefer to use the command line.

Steps to follow:

1. Open a terminal or command prompt and navigate to the Android SDK location (you can find the location by going to Android Studio > Preferences > Appearance & Behavior > System Settings > Android SDK > Android SDK Location).

2. Run the following command to install the latest version of the Android SDK Command-line Tools:

sdkmanager --install "cmdline-tools;latest"

If prompted, accept the license agreement and wait for the installation to finish.

3. Add the following folders to your PATH environment variable: <pathToSDK>/cmdline-tools/latest/bin, <pathToSDK>/tools/bin, and <pathToSDK>/platform-tools. You can do this by editing the .bashrc file on Linux or Mac, or the System Properties > Advanced > Environment Variables on Windows.

4. Restart your terminal or command prompt and run flutter doctor to check if the error is resolved.

If you aren’t an experienced developer, you should avoid using this approach. It is complex, tedious, and error-prone. It requires manual configuration and editing of environment variables. It may cause compatibility issues with the Android SDK or Android Studio if the versions are mismatched.