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

Hi Ashok,

As you said that you did changes in .bashrc and after that node terminal command for appium server is working fine Which is Great! a step closer :slight_smile: .Actually .bashrc file is used for setting variables used by interactive login shells. If you want those environment variables available in Eclipse you need to put them in /etc/environment. if you don’t know how to set /etc/environment, its just a google search away.

You can also define an environment variable that is visible only within Eclipse.
Go to Run -> Run Configurations… and Select tab “Environment”.

Hope This will help you ! Just give a try and let us know.
Thanks,
Donald

Sorry if I’m not being clear. I think Donald had a good point. For me, when I go to run configurations in Eclipse & hit ‘select’, it gives me a list of local variables that I’ve already set & I just pick the one(s) I need. If one is not in there that you need just hit ‘new’, and then set it for Eclipse’s use.

Hello Ashok i had the same issue when i was working in a company before.I usually create a bash file and then use that to open programatically…Here is my code …This will solve the problem

#!/bin/bash
export ANDROID_HOME=/Users/Robot/Downloads/Xamarin/android-sdk-mac_x86
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/build-tools
‘/Applications/Appiumold.app/Contents/Resources/node/bin/node’ ‘/Applications/Appiumold.app/Contents/Resources/node_modules/appium/bin/appium.js’ --address 127.0.0.1 --command-timeout 7200 --pre-launch --app ‘/Users/Robot/Desktop/Exampletools.apk’ --app-pkg Exampletools.exampletool --app-activity bott.droid.SplashScreenActivity --app-wait-activity bott.droid.SplashScreenActivity

As you can see this is the code i stored in my file in Mac pc.Every time you programatically start it needs to set variables each time.I dont understand what is the problem :slight_smile: I hope this fixes your problem

I think if you add the above first 4 lines to ur java code you can make it work.

@Donald @wreed I set those environmental as System-wide environmental variables. and it works now.

Previously I didn’t set the environmental variable(ANDROID_HOME) as system-wide variable, that is the reason why the ANDROID_HOME variable is invisible in Eclipse Environment settings.

To set the ANDROID_HOME as System-wide environmental variable, I have used the following commands in terminal and some settings in Eclipse.

Terminal:

  1. Run sudo nano /etc/launchd.conf
  2. Add setenv ANDROID_HOME /Users/selvakumar/Documents/android-sdk-macosx
  3. Then either restart or run launchctl < /etc/launchd.conf; sudo launchctl < /etc/launchd.conf

Eclipse:
Then the variable becomes visible in the Eclipse–> Run Configurations–> Environment -->Select–>ANDROID_HOME then I checked the ANDROID_HOME variable and click apply. Run the code with your new Run configuration settings. That made my code to work.

@kasperavi Thanks Avinash! Let me check with your idea too…

Thanks a lot to everyone! The big show came to an end :smile: :grinning:

2 Likes

Hi AshokKumar,

I am facing same issue and am new to mac os. Could you please elaborate the steps for setting the ANDROID_HOME as System-wide environmental variables. Currently I am stuck in second step.

Note;- This issue I am getting when starting appium server programmatically. Through Appium GUI it is working fine and am able to run test scripts.

Please find the following Terminal steps.

  1. sudo nano /etc/launchd.conf —> its launching /etc/launched.conf file
  2. I am able enter “setenv ANDROID_HOME /Users/mobilelabmac/Desktop/adt-bundle-mac-x86_64-20140702/sdk/” in /etc/launched.conf file
  3. Save File Using Command + S
  4. Restarting machine

I can’t see the ANDROID_HOME in Select Environment Variables List in Eclipse.

Please elaborate how to save file and after saving /etc/launched.conf file how to run the third steps commands.

I am getting error “No such file error” when I am hitting the command “launchctl < /etc/launchd.conf; sudo launchctl < /etc/launchd.conf” on Terminal

Thanks in advance.

@prasad Sorry for the delay reply.

If you are able execute your scripts through Appium GUI, can you share your Appium start up code and logs

Eclipse is unable to field SDK path. delete and restore or download eclipse.
Thanks

This solution worked for me. Thanks a lot!!

how to tell eclipse to use local varaiables???

Did you use the link provided? If so, which part is confusing?

@nitishram, i had the same issue and got it resolved by adding ANDROID_HOME in the Run Configurations > Environment tab of eclipse. hope it helps to solve yours.

2 Likes

Thanks for replying @praveenmukilan
i have set android path as told by u.but error still exists
my sdk folder is kept in D drive is it k??

reinstalling adt in eclipse solves my problem and working fine

1 Like

Worked perfectly for me…thanx for the response

It worked for me as well. Thanks.

Hi all,

I am facing similar issue
My Setup -
Windows 10 PC + pyCharm+Robot framework+SDK+Appium server

I was able to run the test in this setup before, after Appium server update, I am not able to run any test.
Now I am getting error -

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

Can you please help here,
Thanks,
Nithin

You can watch this video : https://youtu.be/C5OLO6gbX8k

Hi,
I got this in my eclipse console log as an exception. Please help me out. I am using MacOS and the appium server version is 1.5.3. Tried setting up the ANDROID_HOME but of no avail.

Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not find adb in tools, platform-tools, or supported build-tools under /Users/amar/Downloads do you have the Android SDK installed at this location? (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 431 milliseconds
Build info: version: ‘2.48.0’, revision: ‘b7b081a’, time: ‘2015-10-07 15:45:39’
System info: host: ‘Amars-MacBook-Pro.local’, ip: ‘172.16.30.86’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_111’
Driver info: io.appium.java_client.android.AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:113)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:72)
at in.SpekaingTree.SpeakingTreeAppium.main(SpeakingTreeAppium.java:31)