Invalid or unsupported command "update"


Following <https://developer.android.com/tools/agents/android-cli> I run:

curl -fsSL https://dl.google.com/android/cli/latest/darwin_arm64/install.sh | bash 
android update
android init

Problem: At the second step I get:

$ android init
*************************************************************************
The &quot;android&quot; command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command &quot;init&quot;

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk

Update does not work either: Invalid or unsupported command &quot;update&quot;

Question: How to solve this?

It seems that I have two android commands:

  • /usr/local/bin/android that I just installed for android-cli
  • ~/Library/Android/sdk/tools/android from Android Studio

Should I maybe uninstall Android Studio?
I am on macOS, if that matters.

0
Apr 22 at 4:18 AM
User AvatarNicolas Raoul
#android#android-studio#android-cli

Accepted Answer

The problem

You need to reconfigure your PATH so that the new command is found before the old one.

You can confirm that this is the issue by running:

echo $PATH

If that's the issue, you'll see something like ([...] referring to other content):

[...]~/Library/Android/sdk/tools/android:[...]:/usr/local/bin/[...]

Quick fix

Adding something like this to your ~/.zshrc or ~/.bashrc should fix it, but this is a bit of a hack (see below for a better fix).

You can also run this in your terminal to fix it for that session.

export PATH=&quot;/usr/local/bin/:$PATH&quot;

Better fix

Find out what is adding these to the PATH in the wrong order. There are several ways that paths can be added to the PATH, such as (non-exhaustive list) ~/.zshrc, ~/.bashrc, .zprofile, .profile, .bash_profile, /etc/paths (note: not a script), etc.

Whatever is adding it should add the SDK tools to the end of the PATH, not the start, like this:

export PATH=&quot;$PATH:$HOME/Library/Android/sdk/tools/android&quot;
User AvatarRyan M
Apr 22 at 9:17 AM
2