586

Android toolchain - I develop for Android devices (Android SDK version 30.0.3):

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.
1
  • Could you share the flutter doctor summary?
    – abdev
    Jul 3, 2021 at 17:39

25 Answers 25

1150

The solution for me was opening Android Studio and going to SDK Manager, switch to the SDK Tools tab and check Android SDK Command-line Tools (latest).

enter image description here

Don't forget to add to your PATH the tools and platform-tools folder that are inside your SDK.

13
  • 14
    @Felipe-carvalho how do i Don't forget to add to your PATH the tools and platform-tools folder that are inside your Sdk ?
    – Britchi3
    Nov 11, 2021 at 15:16
  • 11
    It only worked for me after I added a bunch of folders to my Ubuntu installation ~/.profile file: export PATH=$PATH:$HOME/Android/Sdk/platform-tools export PATH=$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin/ export PATH=$PATH:$HOME/Android/Sdk/build-tools/32.1.0-rc1/ export PATH=$PATH:$HOME/Android/Sdk/emulator/bin64/
    – Katu
    Apr 4, 2022 at 7:36
  • 13
    On Mac OS : Monterey, after selecting and applying : "Android SDK Command-line Tools (latest)." The SDK Component Installer installs the tools without the requirements to add PATH Jun 4, 2022 at 13:34
  • 61
    Bro , flutter should put the link to your answer in their flutter doctor
    – Ali
    Jul 16, 2022 at 15:36
  • 4
    I love you ... I was about to loose my mind there
    – A Khudairy
    Mar 7, 2023 at 13:16
212

Since my Android Studio starting screen looks different from the answers above, I want to share my solution:

An image of the 'Welcome to Android Studio' screen. An arrow highlights the "More Actions" dropdown menu on the bottom of this screen, and a second arrow highlights the "SDK Manager" option within the dropdown menu.

  • Open Android Studio and click on 'more actions' on the welcome screen.

  • Click on 'SDK Manager'

    An image of the "Preferences" window within Android Studio. "Android SDK" is selected on the left, then on this settings page, "SK Tools is selected from a top-bar menu. The item called "Android SDK Command-line Tools (latest)" is checked, and changes are applied.

  • In the 'Preferences' window go to the 'SDK Tools' tab

  • Select the 'Android SDK Command-line Tools (latest)' checkbox.

  • Click on Apply.

3
  • 11
    This solved the issue. Worth mentioning that last step is: flutter doctor --android-licenses
    – Ermal
    Jun 20, 2022 at 14:25
  • This is the correct solution for Mac users
    – Ahsan
    Apr 24, 2023 at 4:18
  • ur screen is because u did not have any project created
    – cyril
    May 22, 2023 at 6:00
141

Android SDK Manager screenshot on Windows

Enter image description here

Please see the attached screenshot for installing tools from SDK Manager.

0
125
  1. Open SDK Manager from your Android Studio.

  2. You can find SDK manager from the menubar → ToolsSDK Manager or use the icon. As in the picture.

    Enter image description here

  3. SDK Tools tab

  4. Check Android SDK Command Line Tools as in the picture

  5. Apply

    Enter image description here

  6. Then again run flutter doctor in your terminal.

0
62

My solution process is as follows:

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

    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
        ... 5 more
    
  2. Install Android SDK Command-line Tools in Android Studio:

    PreferencesAppearance & BehaviorSystem SettingsAndroid SDKSDK ToolsAndroid SDK Command-line Tools (latest)

  3. flutter doctor

    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!
    
5
  • I like these steps! Let me know we are same errors, then can keep with the solution!
    – Tokenyet
    Dec 22, 2021 at 4:35
  • 1
    For me just step 2 resolved the Issue. Dec 30, 2021 at 0:54
  • 3
    Beyond these operations I had to execute this command on the 'flutter doctor --android-licenses' to accept all Android lincenses
    – Ricla
    Feb 20, 2022 at 14:13
  • Step 2 can also be found by following instructions posted by Md. Shahariar Hossen below.
    – Space
    Jul 29, 2022 at 21:05
  • Flutter devs should really take a page from your solution sir. This worked!
    – Aadn
    Aug 16, 2022 at 2:38
49

For Windows users

If you still see the same error even after your build tools, tools are installed and added to the user/system path variable, and maybe your sdkmanager location is really not found

  • Just type in
flutter config --android-sdk "C:\Users\{Your_User_Name}\AppData\Local\Android\Sdk" # (Default SDK location)
  • Add the path inside "" to where your Android SDK folder is located

  • Then you can run the licenses to verify any license which is not approved.

This worked for me.

3
  • 7
    Extremely helpful! Because of storage shortage, I had to move my sdk folder to D drive, that's why even after intalling the tools and setting the path the issue persisted! Your solution saved me a lot of time!
    – William Le
    Nov 10, 2021 at 14:18
  • 1
    thank you, for my case i installed sdk in D:\sdk, i just need to run command above with my sdk path and it's working now.
    – apripuppey
    Jun 8, 2022 at 6:31
  • 1
    That was the missing step for my chromeos / debian install. Thank you
    – M. Hoffman
    Jul 12, 2022 at 2:04
30

Your Android SDK version requires an update.

Open Android Studio → click Android Studio on the top bar → PreferencesAppearance & behavior (click to open the dropdown) → System Settings (click to open the dropdown) → Android SDKSDK Tools (tab).

Check Android SDK Command-line Tools (latest)Apply → click OK. Once the update has finished, run flutter doctor.

Screenshot of the Appearance & Behavior menu

0
26

If what flutter doctor said was something like:

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/<admin>/Library/Android/sdk
✗ cmdline-tools component is missing
  Run `path/to/sdkmanager --install "cmdline-tools;latest"`

The path/to/sdkmanager for me was:

/Users/<user>/Library/Android/sdk/tools/bin/sdkmanager

So what solved the whole thing for me was running:

/Users/<user>/Library/Android/sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"
2
  • 4
    What worked for me was running: flutter config --android-studio-dir="" and flutter config --android-sdk=""
    – wamae
    Oct 25, 2021 at 13:12
  • Clearing these values finally resolved the issue for me, after trying a plethora of solutions. Thanks !
    – Yasper
    Dec 11, 2023 at 20:52
25

For macOS, I ran this command;

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

Then when I ran the flutter doctor command again, it confirmed that the problem was solved.

1
  • I don't have the tools folder inside ~/Library/Android/sdk/ Feb 19 at 13:08
16

Enter image description here

Easiest solution:

  • Open Android Studio and click settings in the upper left corner of Android studio.
  • Search for "SDK tools" in the search box.
  • From the SDK tools just check the Android SDK Platform Tools.
  • Run flutter doctor to verify. You can also restart Android Studio if you want.
    I hope the problem will be solved.
0
16

For macOS users:

flutter config --android-sdk "/Users/{YOUR_USER_NAME}/Library/Android/sdk"

Then

flutter doctor --android-licenses

Type "y" for all stops.

1
  • At last, something solved it for me!
    – FreakyAli
    Sep 19, 2023 at 2:06
11

If you have already downloaded cmdline-tools and the Android SDK, make sure Flutter isn't looking in the wrong directory with:

flutter config --android-sdk=""
3
  • 1
    Is "cmdline-tools" literal or do you mean "command line tools"? Aug 19, 2022 at 11:35
  • OK, the OP has probably left the building. We will probably never know. Oct 17, 2023 at 0:51
  • cmdline-tools is literal, it's the name of the component, it refers to specific command line tools for flutter named cmdline-tools.
    – Mstrdav
    Nov 5, 2023 at 13:46
10

I solved this problem on Windows 10 with the following actions:

  1. Run the following command in a Windows command prompt or Flutter console:

    flutter config --android-sdk "C:\Users\'your computer name' AppData\Local\Android\Sdk"
    

    (you may need to find and enter your own SDK path)

    The Android SDK location could be found in the Android Studio application* → Appearance & BehaviorSystem SettingsAndroid SDK

  2. Open your Android Studio, and then → FileSettingsAppearance & BehaviorSystem SettingsAndroid SDKSDK Tools → download Android SDK Command-line Tools (latest) and you are good to go.

5

If you are a Mac user, just open your terminal and paste:

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

And hit Enter.

This command will install the latest version of cmdline-tools.

Then, run flutter doctor, and the error will be gone.

0
5

For Linux (Ubuntu)

Just copy this command in your terminal and change 'your user name' with your user name without spaces:

/home/your user name/Android/Sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"
5

I installed the Android SDK platform tool from Android Studio. This helped me to resolve this error.

Error before installation

Installed platform tool from Android Studio

After installation of Platform tools

3
4

You have to install Android SDK Command-line Tools. To do that, invoke the menu command FileSettingsAndroid SDK and download the latest.

You must choose Android SDK on the left side of the Settings window. It’s under Appearance & BehaviorSystem Settings.

3

On Windows I did two things to resolve it.

  1. Launched Android Studio > More Actions > SDK Manager>SDK Tools and ticked and applied Android SKD Command line tools

  2. Entered flutter config --android-sdk C:\Users\xxx\AppData\Local\Android\Sdk into the command line. The path came from the top of the screen in step 1.

3

Install the Android SDK Command-line Tools:

  • For the updated version of Android Studio, the Setting is here:
Settings > Languages & Framework > Android SDK > SDK Tools (TAB)

Android SDK Command-line Tools

  • For older version:
Settings > Appearance & Behavior > System Settings > Android SDK > SDK Tools (TAB)

Android SDK Command-line Tools

2

This is for Windows: If you are still facing the issue even after installing the "Android SDK Command-line Tools(latest)" thru Android Studio -> Settings->Appearance & Behavior -> Systems Settings -> Android SDK -> SDK Tools, You need to configure the flutter for Android SDK Path (Not the environment variable path).

Android SDK Will be installed under Program files e.g. (C:\Program Files (x86)\Android\android-sdk). If not this location, find out the location where it is installed and go to the bin folder (C:\Program Files (x86)\Android\android-sdk\cmdline-tools\7.0\bin) and run

flutter config --android-sdk "C:\Program Files (x86)\Android\android-sdk"

After this run flutter doctor, now this issue should be resolved.

2

For macOS users

If you already have Android Studio installed, simply run:

flutter config --android-sdk "/Users/$USER/Library/Android/sdk" & flutter doctor --android-licenses
1

If you have installed the latest cmd-line tools from Android Studio, but it still gives the error, then you should do the following.

If you have installed the Android SDK to a custom directory, then you need to copy the path of your SDK folder. Then you have to go to the edit environment variable, click New give a variable name: ANDROID_SDK_ROOT. And a variable value: path of your SDK folder. Click OK.

In the older version of Flutter, this error came with the solution (creating ANDROID_SDK_ROOT), but in the new versions it does not show that.

1

For me, running this command worked perfectly:

flutter config --android-sdk /path/to/your/sdk
2
  • On what system, incl. edition and version information (both for the environment, like the operating system, and for Flutter)? Oct 17, 2023 at 0:30
  • At that time, I was using - MacBook Pro (Retina, 15-inch, Mid 2014) with macOS BigSur (11.7.9). Flutter (Channel stable, 3.7.0, on macOS 11.7.9 20G1426 darwin-x64, locale: en-US). As it was almost one year ago, now using newest m2 macbook, so far, no such problem. Oct 17, 2023 at 8:17
1

Goto:

  1. Tool->SDK Manager and Apply SDK command line toolkit.

enter image description here

0

I executed the below command to fix the issue on Mac:

/Users/<user username>/Library/Android/sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"

Not the answer you're looking for? Browse other questions tagged or ask your own question.