ANDROID_HOME setting in MAC is working for Appium desktop but not programatically

Hi All,

I could able to launch the app using appium desktop but not using Java program. I am using latest version of Android studio. appium-doctor is working fine, adb devices is working fine. Is there any issue with latest Android Studio ?

Error stack trace :slight_smile:UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb’ in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the corect Android SDK root directory path.
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:388:37)

This path /usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js means you installed node.js incorrectly. The node_modules directory should be located within a nodejs directory within usr/local/lib directory.

I recommend that you uninstall node.js and then install it manually (download compressed tarball and extract its contents to /usr/local/lib/nodejs, which you must create). For instance:

~$ sudo mkdir -p /usr/local/lib/nodejs
~$ sudo chown ${USER}:${USER} /usr/local/lib/nodejs
~$ tar -xJvf ~/Downloads/node-v12.13.1-darwin-x64.tar.xz -C /usr/local/lib/nodejs

Then set paths in the .bash_profile file.

export ANDROID_HOME=/Users/cesar/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
export NODE_PATH=/usr/local/lib/nodejs/node-v12.13.1-darwin-x64/bin
export APPIUM_PATH=/usr/local/lib/nodejs/node-v12.13.1-darwin-x64/bin

export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platforms-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/debian
export PATH=${PATH}:${JAVA_HOME}/bin
export PATH=${PATH}:${NODE_PATH}

Log out and back in, and then install Appium.

npm install -g appium
npm install -g wd
npm install -g appium-doctor

P.D.: set the ANDROID_HOME and JAVA_HOME environment variables to the corresponding paths of your system.

Make sure you set the environment variables in the file .bash_profile. The file .profile corresponds to Linux, and I do not know if macOS sources this specific version.

I’ve set up Appium on both OSes and I previously pointed you to the wrong file.

Hi Cesarv, I got issue resolved by setting the ANDROID_HOME path in eclipse. By setting environment variables in .profile in MAC the app started working.