Shafiq Ahmed Khan
Shafiq Ahmed Khan

Reputation: 179

Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path

I am getting the below error message:

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. 
(Selenium::WebDriver::Error::UnknownError)

I have setup all the below:

info AppiumDoctor Appium Doctor v.1.4.2
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor  ✔ The Node.js binary was found 
at:/usr/local/bin/node
info AppiumDoctor  ✔ Node version is 7.10.0
info AppiumDoctor  ✔ ANDROID_HOME is set to: 
/Users/shafiq.malik/Library/Android/sdk
info AppiumDoctor  ✔ JAVA_HOME is set to: /Library/Java/Home
info AppiumDoctor  ✔ adb exists at: 
/Users/shafiq.malik/Library/Android/sdk/platform-tools/adb
info AppiumDoctor  ✔ android exists at: 
/Users/shafiq.malik/Library/Android/sdk/tools/android
info AppiumDoctor  ✔ emulator exists at: 
/Users/shafiq.malik/Library/Android/sdk/tools/emulator
info AppiumDoctor  ✔ Bin directory of $JAVA_HOME is set
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor

I am not sure what I am missing. Can somebody please advise?

Upvotes: 6

Views: 27053

Answers (4)

NITIN SURANGE
NITIN SURANGE

Reputation: 524

Sometimes this error occurs due to changing in shell for terminal.

If you previously working with .bash profile and sudden if terminal updated to zsh then your .bash profile will not work for setting ANDROID_HOME and other paths.

So you need to change by default again to bash profile as below.

ZSH to BASh shell

With macOS Catalina, Apple is now using Zsh as the default shell. We love Zsh, but the trusty old Bash shell is still included with macOS, and you can quickly switch back to Bash if you prefer. Zsh is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded  Mac will still use Bash by default unless you change it. Each user account has its own default shell preference.

From the Terminal To change a user account’s default shell on macOS, simply run the chsh -s (change shell) command in a Terminal window.

Change the default shell to Bash by running the following command:

chsh -s /bin/bash

You’ll have to enter your user account’s password. Finally, close the Terminal window and reopen it. You’ll be using Bash instead of Zsh.

Change the default shell back to Zsh by running this command:

chsh -s /bin/zsh

Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Zsh.

You can see a list of included shells you can select by running the following command:

cat /etc/shells

Upvotes: 0

Khan Here
Khan Here

Reputation: 18

After troubleshooting the same issue for a few hours here is what worked for me and should work for you too:

  1. Check if you have already set environment variables ANDROID_HOME and JAVA_HOME i.e. in ~/.bash_profile for Mac.
  2. If environment variables are already set in your machine then set ANDROID_HOME and JAVA_HOME from Appium Desktop by clicking on Edit Configurations from Appium Home screen.

I hope it works for you as well. Have fun

Upvotes: 0

Hassan Rahman
Hassan Rahman

Reputation: 5203

For Windows 10:

  1. Right-click on 'My Computer' and select 'Properties'. Then select 'Advance System Settings' from Left Panel. Select 'Environment Variables' from new pop-up window.

  2. Add variable 'ANDROID_HOME' with value of 'C:\Program Files (x86)\Android\android-sdk'.

  3. Close all the windows and restart the Appium. (Important)

It works for me.

Upvotes: 2

Kaustav Das
Kaustav Das

Reputation: 111

You need to add the path to the android-sdk to ANDROID_HOME environment variable. e.g. C:\installation-location\android-sdk or /opt/intallation-location/android-sdk

In Windows 8 & 10:

  1. In Search, search for and then select: System (Control Panel)
  2. Click the Advanced system settings link.
  3. Click Environment Variables. If the ANDROID_HOME environment variable does not exist, click New.
  4. In the Edit System Variable (or New System Variable) window, specify the value of the ANDROID_HOME environment variable. Click OK. Close all remaining windows by clicking OK.

In Linux:

  1. Edit /etc/environment file.
  2. Append the line export ANDROID_HOME="/opt/intallation-location/android-sdk"
  3. Save the file and then log out and log in.

Upvotes: 2

Related Questions