"zsh: command not found: adb" after adding ANDROID_HOME and PATH variables to .zshrc

1.3k Views Asked by At

I'm trying to run a React Native app through Expo Go using npm expo start.

I've installed Android Studio and located my Android SDK folder in C:\Users\username\AppData\Local\Android\Sdk, then added this path to the ANDROID_HOME and PATH variables in .zshrc as follows:

export ANDROID_HOME=$HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH

After reloading with source ~/.zshrc I try to run adb in the terminal and get:

zsh: command not found: adb

However, I can run adb directly with $HOME/../../mnt/c/Users/username/AppData/Local/Android/Sdk/platform-tools/adb.exe (I have to add the .exe explicitly or else it won't run).

I suspect that I may have added the incorrect paths in .zshrc, added them to the wrong file, or that the SDK folder is in the wrong place.

I've looked over several similar issues, which all recommend adding the same PATH variables despite many people having their SDK folders located differently (in /Users/username/Library/Android/sdk, for example).

I'm still very new to Android Studio and adding PATH variables, so any advice would be greatly appreciated.

1

There are 1 best solutions below

3
svlasov On BEST ANSWER

To run adb.exe in shell as adb you have the following options (pick one of them):

  • Create a symlink:
cd platform-tools
ln -s adb.exe adb
  • Create an alias. Put to .zshrc:
alias adb="adb.exe"
  • Define a shell function. Put to .zshrc:
adb() {
  adb.exe $@
}