Skip to content

Android SDK "cmdline-tools component is missing" Error

When setting up Flutter development with Android Studio, many developers encounter the error message: "cmdline-tools component is missing." This error typically appears when running flutter doctor and indicates that the Android SDK command-line tools aren't properly installed or configured.

Problem Overview

The error message appears as:

X cmdline-tools component is missing
  Run `path/to/sdkmanager --install "cmdline-tools;latest"`
  See https://developer.android.com/studio/command-line for more details.

This occurs because Flutter's development tools require the Android SDK command-line utilities to function properly, but they're either missing or not properly detected.

The most straightforward solution is to install the command-line tools through Android Studio's interface:

For Android Studio 2020.3 and Later

  1. Open Android Studio
  2. Go to SettingsLanguages & FrameworksAndroid SDKSDK Tools tab
  3. Check Android SDK Command-line Tools (latest)
  4. Click Apply or OK to install

Android SDK Tools selection in newer Android Studio versions

For Older Android Studio Versions

  1. Open Android Studio
  2. Navigate to FileSettingsAppearance & BehaviorSystem SettingsAndroid SDKSDK Tools tab
  3. Select Android SDK Command-line Tools (latest)
  4. Click Apply

Android SDK Tools selection in older Android Studio versions

Alternative Access Methods

If you don't see the standard menu options:

  • From the welcome screen: Click More ActionsSDK Manager
  • From the menu bar: ToolsSDK Manager

Solution 2: Manual Installation via Command Line

If the GUI method doesn't work or you prefer command-line tools:

macOS/Linux

bash
cd ~/Library/Android/sdk/tools/bin
./sdkmanager --install "cmdline-tools;latest"

Windows

bash
cd %LOCALAPPDATA%\Android\Sdk\tools\bin
sdkmanager --install "cmdline-tools;latest"

Ubuntu/Linux with Custom Path

bash
/home/your_username/Android/Sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"

Java Version Compatibility

If you encounter Java errors when running sdkmanager, ensure you have a compatible Java version installed. The command-line tools may require specific Java versions to function properly.

Solution 3: Configure Flutter SDK Path

If the tools are installed but Flutter can't find them, explicitly set the Android SDK path:

bash
flutter config --android-sdk "PATH_TO_YOUR_SDK"

Common SDK Paths by OS

bash
flutter config --android-sdk "/Users/$USER/Library/Android/sdk"
bash
flutter config --android-sdk "C:\Users\YourUsername\AppData\Local\Android\Sdk"
bash
flutter config --android-sdk "/home/your_username/Android/Sdk"

After setting the path, accept the Android licenses:

bash
flutter doctor --android-licenses

Type "y" to accept all licenses when prompted.

Solution 4: Environment Variables Setup

For persistent configuration, set the ANDROID_SDK_ROOT environment variable:

Windows

  1. Open System Properties → Environment Variables
  2. Create a new system variable:
    • Name: ANDROID_SDK_ROOT
    • Value: Path to your SDK (e.g., C:\Users\YourUsername\AppData\Local\Android\Sdk)

macOS/Linux

Add to your shell profile (.bashrc, .zshrc, or .profile):

bash
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools/bin"

Verification and Troubleshooting

After applying any solution, verify the fix by running:

bash
flutter doctor

If the issue persists:

  1. Ensure you've restarted your terminal/command prompt after making changes
  2. Confirm the SDK path is correct with flutter config --android-sdk
  3. Check that the command-line tools are actually installed in the SDK directory
  4. Try running flutter doctor -v for more detailed information

Complete Setup Script

For Linux users looking for a comprehensive setup solution, there's an automated installation script that handles SDK setup, Flutter installation, and path configuration.

Conclusion

The "cmdline-tools component is missing" error is a common but easily solvable issue in Flutter development. The recommended approach is to install the tools through Android Studio's SDK Manager, but command-line installation and path configuration are effective alternatives. Once resolved, you'll have a properly configured Android development environment for Flutter projects.