The Problem:
An Android developer encountered an error message while setting up Android Studio for mobile app development. The error message states that the "cmdline-tools component is missing" and suggests running a command to install it. The developer seeks assistance in resolving this issue.
The Solutions:
Solution 1: Android Studio SDK Manager
- Open Android Studio and access the SDK Manager.
- Select the ‘SDK Tools’ tab.
- Check the checkbox for ‘Android SDK Command-line Tools (latest)’.
- Click ‘Apply’ to apply the changes and install the command-line tools.
Remember to include the tools and platform-tools directories within your SDK in your PATH environment variable.
Solution 2: Use Android Studio SDK Manager
If your Android Studio starting screen appears different, try this solution:
- Open Android Studio and click ‘more actions‘, located at the bottom of the welcome screen.
- Select ‘SDK Manager‘.
- In the ‘Preferences‘ window, navigate to the ‘SDK Tools‘ tab.
- Check the ‘Android SDK Command-line Tools (latest)‘ checkbox.
- Click ‘Apply‘ to save changes.
With this method, you can install the missing ‘cmdline-tools’ component through Android Studio’s built-in SDK Manager.
Solution 3: Installing Tools from SDK Manager
Open the SDK Manager by running the following command in your terminal:
sdkmanager
In the SDK Manager, navigate to the "SDK Tools" tab.
Locate and select the "Android SDK Command-line Tools" component.
Click the "Install" button to install the component.
Once the installation is complete, restart Android Studio.
Solution 4: Open SDK Manager
-
Open SDK Manager from Android Studio.
-
You can find the location from the menubar → Tools → SDK Manager or use the icon.
-
Go to the SDK Tools tab.
-
Select Android SDK Command Line Tools as shown in the image.
-
Click on <kbd>Apply</kbd>.
-
Run
flutter doctor
again in the terminal.
Solution 5: Install Android SDK Command-line Tools in Android Studio
To install the Android SDK Command-line Tools in Android Studio, follow these steps:
- Open Android Studio and go to Preferences → Appearance & Behavior → System Settings → Android SDK → SDK Tools.
- In the SDK Tools tab, select the Android SDK Command-line Tools (latest) checkbox.
- Click Apply and then OK.
After following these steps, the Android SDK Command-line Tools will be installed in Android Studio. You can verify this by running the following command in your terminal:
flutter doctor
If the command-line tools are installed correctly, you should see a message similar to the following:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] Connected device (2 available)
• No issues found!