I am getting error "cmdline-tools component is missing" after installing Flutter and Android Studio... I added the Android SDK. How can I solve them?

175,599

Solution 1

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.

Solution 2

Android SDK Manager screenshot on Windows

Enter image description here

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

Solution 3

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'.

Solution 4

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!
    

Solution 5

  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

Share:
175,599
Stark
Author by

Stark

Updated on July 20, 2022

Comments

  • Stark
    Stark almost 2 years

    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.
    
    • abdev
      abdev almost 3 years
      Could you share the flutter doctor summary?
  • John Weidner
    John Weidner over 2 years
    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)
  • Donald Duck
    Donald Duck over 2 years
  • wamae
    wamae over 2 years
    What worked for me was running: flutter config --android-studio-dir="" and flutter config --android-sdk=""
  • Sean William
    Sean William over 2 years
    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!
  • Britchi3
    Britchi3 over 2 years
    @Felipe-carvalho how do i Don't forget to add to your PATH the tools and platform-tools folder that are inside your Sdk ?
  • Felipe Carvalho
    Felipe Carvalho over 2 years
    Depends on your operating system. This tutorial (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.
  • Tokenyet
    Tokenyet over 2 years
    I like these steps! Let me know we are same errors, then can keep with the solution!
  • sigma1510
    sigma1510 over 2 years
    This comment right here. @wamae definitely worth its own answer.
  • Dhyaan
    Dhyaan over 2 years
    So far this is the most accurate answer. Thank you.
  • Vysakhan Kasthuri
    Vysakhan Kasthuri over 2 years
    For me just step 2 resolved the Issue.
  • Peter Mortensen
    Peter Mortensen over 2 years
    Can you provide the first and the last image as text instead, please? Thanks in advance.
  • José Neto
    José Neto over 2 years
    You saved my day! <3
  • Md. Shahariar Hossen
    Md. Shahariar Hossen over 2 years
    @JoseNeto You are welcome!
  • Ricla
    Ricla about 2 years
    Beyond these operations I had to execute this command on the 'flutter doctor --android-licenses' to accept all Android lincenses
  • Katu
    Katu about 2 years
    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/
  • nimey sara thomas
    nimey sara thomas almost 2 years
    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
  • apripuppey
    apripuppey almost 2 years
    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.
  • Ermal
    Ermal almost 2 years
    This solved the issue. Worth mentioning that last step is: flutter doctor --android-licenses