Getting error In Mac when running appium from terminal "Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported"

Hi

I have tried running appium from MAC and terminal both and found that script always fail when running appium form terminal and gives error “Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported”. On other end if I run appium from GUI it works absolutely fine . I have attached screenshot of error . Please help me provide solution for this issue. I tried few solutions from google but doesn’t work for me. My bash file is also correct I think. Here is content
export ANDROID_HOME=/Users/xxxyyyzzz/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/xxxyyyzzz/.android/avd
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_SDK_ROOT:$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export JAVA_HOME=/Library/Java/Home

Probably you aren’t using BASH. Since 2019, Mac OS has defaulted to ZSH. You can check which one you are using with this command:

echo $SHELL

Here is an article explaining how to add environment variables to either of them:

https://niklasmtj.de/blog/set-environment-variable-macos-linux

1 Like

add this to your .zshrc which is in your HOME directory and then run source command with it.

as well, you can run ls -a to view all you hidden files in your HOME directory.

Thank you so much for your help . I added environment variables to ~/.bashrc file and it works :slightly_smiling_face: :partying_face: