Search code examples
androidflutterandroid-studioubuntu

While installing cmdline-tools for flutter on Ubuntu, get KeyError: ('cmdline-tools', 'latest')


I installed the android sdk on Ubuntu 22 using the command:

apt install android-sdk

When I run

flutter doctor

I am getting the following error:

cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`

I tried installing the missing component using the command:

sdkmanager --install "cmdline-tools;latest"

but I received an error message saying that the command was not found.

So, I installed it using apt-get install sdkmanager

But now, when I run sdkmanager --install "cmdline-tools;latest", I receive the following error message:

Traceback (most recent call last):
  File "/usr/bin/sdkmanager", line 33, in <module>
    sys.exit(load_entry_point('sdkmanager==0.5.1', 'console_scripts', 'sdkmanager')())
  File "/usr/lib/python3/dist-packages/sdkmanager.py", line 1077, in main
    method(args.packages)
  File "/usr/lib/python3/dist-packages/sdkmanager.py", line 891, in install
    url = packages[key]
KeyError: ('cmdline-tools', 'latest')

I have no idea how to solve this problem.

Thanks.

[EDIT] I don't have GUI access to my machine, only terminal


Solution

  • I eventually solved it by installing the real command line tool from https://developer.android.com/studio/command-line#tools-sdk (not the one using apt install)

    Then, in /root/cmdline-tools/bin I called:

    ./sdkmanager --sdk_root=/usr/lib/android-sdk/ --install "cmdline-tools;latest"