adbzshandroid-sdk-manager

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


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.


Solution

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

    cd platform-tools
    ln -s adb.exe adb
    
    alias adb="adb.exe"
    
    adb() {
      adb.exe $@
    }