Original error: Could not find adb Please set the ANDROID_HOME environment variable

Hi everyone,

Relatively new to Appium, apologize in advance! I keep running into an issue whenever I try to start an Appium session:

"An unknown server-side error occurred while processing the command. Original error: Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path."

I believe my bash_profile is set correctly (let me know otherwise):

export ANDROID_HOME=/Users/chris.carela/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export NODE_PATH=usr/local/bin/node

Things to note:

  • typing adb devices in Terminal does list my Android devices
  • Hardware: MacOS High Sierra
  • NPM/Appium GUI Version: 5.6.0/1.1.0
  • Tried setting up Appium Doctor but it states that a package.json file is missing

Any ideas?

Thanks in advance!

Are you getting this error in some kind of IDE?

In the Appium Desktop application.

I can’t tell what version you are using. Can you try 1.5.0 from here:

@chris-carela This is environment issue, can you check ANDROID_HOME path in your terminal by “echo $ANDROID_HOME”, try it in new terminal window.

I don’t seem to get any info when I run this command in Terminal. I uploaded a screenshot of my .bash_profile set up below as well.

This is what I’m getting in the Appium logs whenever I attempt to “Start Session”.

Appium logs

As I said before, reinstall, make sure you are on the latest version. Here is a troubleshooting list you can use, but if it’s not working you should reinstall:

in Eclipse go to Run > run configuration > Environment tab > tap on new > set ANDROID_HOME variable and JAVA_HOME Variable > Apply > Run… hopefully this will resolve this issue.

This person has not said they are using an IDE. They say it’s just in Appium Desktop that this happens. Look at the screenshots.

Actually, I am going to write my test in Eclipse but this specific issue is with Appium Desktop. I’ll keep this in mind once I figure this issue out though.

below is what my bash profile is setup, and I am not facing any issue,

export ANDROID_HOME="/usr/local/share/android-sdk"
export JAVA_HOME=/usr/libexec/java_home -v 1.8
export PATH=$PATH:$ANDROID_HOME:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:$JAVA_HOME$

additionally, please check the permission of your SDK folder.

@chris-carela I also faced same issue few days ago, can you please check which shell you are using? using command “echo $0”. In my case I was using “zsh” instead of “bash”

Typing echo $0 returns -sh for me, is this correct?

I should be “bash” instead of “sh”, just change shell to bash using command “chsh -s bash”
Please verify after this :blush:

Also try ‘echo $SHELL’ to see what the default shell is. I think this is what Appium Desktop will use also. Mine:

wreed$ echo $SHELL
/bin/bash

Remember that other shells will not necessarily read the bash config files.

I changed the default shell to /bin/bash and tried to relaunch Appium but I’m still getting the same error. However, I’m noticing that the Appium logs state that:

[ADB] Checking whether adb is present
[ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.

According to my bash_profile, this is already specified.

export ANDROID_HOME=/Users/chris.carela/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export NODE_PATH=usr/local/bin/node

I even made sure to drag that sdk folder into Terminal to copy/paste that path directly into my bash_profile.

Did you log out & back in or make a new terminal window? You could also try sourcing the configs:

source ./.bash_profile

^^^In your home directory.

Then check to make sure things are set by using the echo command on the $ANDROID_HOME

More info here:

It works now! I reconfigured the bash_profile according to the guide, rebooted my computer, and, sourced the new bash config.

Thank you everyone!

1 Like

@chris-carela Welcome!
If you want to get good learning on mobile application automation or Appium, Have a look at my youtube channel: https://www.youtube.com/c/MobileAutomation and subscribe for latest videos.