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 "android" 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 "init"
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 "update"
Question: How to solve this?
It seems that I have two android commands:
Should I maybe uninstall Android Studio?
I am on macOS, if that matters.
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/[...]
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="/usr/local/bin/:$PATH"
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="$PATH:$HOME/Library/Android/sdk/tools/android"