201

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.
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Stark
  • 2,013
  • 2
  • 4
  • 6

18 Answers18

426

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Felipe Carvalho
  • 4,436
  • 1
  • 8
  • 5
  • 3
    @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 '21 at 15:16
  • 1
    Depends on your operating system. This tutorial (https://gist.github.com/nex3/c395b2f8fd4b02068be37c961301caa7) provides a way of adding folders to your PATH environment variable on the most used OSs. Look for your Android SDK folder, and you'll find the "tools" and "platform-tools" folder. – Felipe Carvalho Nov 23 '21 at 19:31
  • 1
    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 04 '22 at 07:36
  • 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 – nimey sara thomas Jun 04 '22 at 13:34
95

Android SDK Manager screenshot on Windows

Enter image description here

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

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
jnsnsml
  • 960
  • 2
  • 6
52

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

enter image description here

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

enter image description here

  • In the '*Preferences' window go to the '*SDK Tools•' tab
  • Select the 'Android SDK Command-line Tools (latest)' checkbox.
  • Click on 'Apply'.
Norman
  • 1,005
  • 6
  • 16
51

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!
    
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
jqgsninimo
  • 5,784
  • 1
  • 32
  • 28
35
  1. Open SDK Manager from your Android Studio.
  2. SDK Tools tab
  3. Check Android SDK Command Line Tools as in the picture
  4. Apply.
  5. Then again run flutter doctor.

Enter image description here

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
infomasud
  • 1,085
  • 9
  • 12
21

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"
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
regina_fallangi
  • 1,918
  • 17
  • 35
20

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Enes Karaosman
  • 1,661
  • 19
  • 27
15

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

Try this

  • Just type in

    flutter config --android-sdk "C:\Users\barma\AppData\Local\Android\Sdk" (since my SDK folder is here)
    
  • Add the path inside "" to where your Android SDK folder is located

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

This worked for me.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
  • 2
    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! – Sean William Nov 10 '21 at 14:18
12

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.
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
5

Your Android SDK version requires an update.

Open Android Studio

Android Studio (or File if using older version) -> Preferences -> Appearance & behavior -> System Settings (dropdown) -> Android SDK -> SDK Tools -> check Android SDK Command-line Tools (latest) -> Apply -> click OK once update has finished -> Run flutter doctor. Screenshot of the Appearance & Behavior menu

Sharon
  • 171
  • 2
  • 5
4

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
3

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Prajeet Naga
  • 226
  • 1
  • 7
  • 6
    On my mac, running the above gives the error ClassNotFoundException: javax.xml.bind.annotation.XmlSchema. But installing the command line tools from within Android Studio resolved the issue. Preferences > Appearance & Behavior > System Settings > Android SDK > SDK Tools > Android SDK Command-line Tools (latest) – John Weidner Sep 23 '21 at 19:37
3

For Mac OS users:

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

then

flutter doctor --android-licenses

Types for all stops "y"

Kaloglu
  • 1,402
  • 1
  • 18
  • 29
2

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"
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
pola wahba
  • 21
  • 3
2

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=""
Mstrdav
  • 21
  • 4
1

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

Error before installation

Installed platform tool from Android Studio

After installation of Platform tools

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
1

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

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

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Dinith
  • 619
  • 10
  • 20
0

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124