Error: Appium not working is non GUI mode

Machine: Mac 10.10, Appium Appium v1.3.3

In GUI every thing is working fine, but in non gui mode below error is coming at appium and I am not able to create a session.

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.

I have set ANDROID_HOME in …bash_profile with following values
export ANDROID_HOME=/Applications/android-sdk-macosx
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

After executing the command when I do ps -eaf | grep node, it showing me an instance is running.

To start appium I am using below
appiumApp = ivProp.getProperty(“APPIUM_EXE”);
nodejs = ivProp.getProperty(“APPIUM_NODEJS”);
command.addArgument(appiumbasepath + appiumApp);
command.addArgument(appiumbasepath + nodejs);
command.addArgument("–address");
command.addArgument(ivProp.getProperty(“APPIUM_IP”));
command.addArgument("–port");
command.addArgument(ivProp.getProperty(“APPIUM_PORT”));
command.addArgument("–no-reset");
command.addArgument("–log");
command.addArgument(ivProp.getProperty(“APPIUM_LOG_PATH”));
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);

		try {
			executor.execute(command, resultHandler);
			return true;
		} catch (IOException e) {
			System.out.println("IO exception " + e);
			e.printStackTrace();
		} catch (Exception e) {
			System.out.println("Exception " + e);
		}

below is trace of Appium

2014-11-26 09:44:29:185 - warn: 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.
2014-11-26 09:44:29:199 - info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
2014-11-26 09:44:36:204 - warn: UiAutomator did not shut down fast enough, calling it gone
2014-11-26 09:44:36:205 - info: [debug] Cleaning up android objects
2014-11-26 09:44:36:205 - info: [debug] Cleaning up appium session
2014-11-26 09:44:36:206 - error: Failed to start an Appium session, err was: Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
2014-11-26 09:44:36:207 - info: [debug] Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:113:12)
at ChildProcess.exithandler (child_process.js:652:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
2014-11-26 09:44:36:208 - info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)”,“origValue”:“Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.”},“sessionId”:null}
2014-11-26 09:44:36:214 - info: <-- POST /wd/hub/session 500 7042.276 ms - 342

Can anyone help me what I am doing wrong?

I am not sure what’s exactly installed under your folder /Applications/android-sdk-macosx

Just make sure you have the correct adt framework (download from here: http://developer.android.com/sdk/index.html) and unpack it (in my case $HOME/adt)

This is how I set it up on my machine (~/.bash_profile as well):

export ANDROID_HOME="$HOME/adt/sdk"
export PATH=${PATH}:$HOME/adt/sdk/tools
export PATH=${PATH}:$HOME/adt/sdk/platform-tools

export JAVA_HOME=$(/usr/libexec/java_home)

b.t.w, any chance you’re using something other than regular bash? Maybe zsh?
If so, do the same in your ~/.zshrc settings file.

Let me know if any of these works.

thanks alot, the issue was with my eclipse itself, I updated it with regular adt and it started working,

Hi Sachin Chauhan,

I am also facing same issue…please help to resolve this,

Error log:

minfoe[39m: Starting android appium
e[36minfoe[39m: [debug] Using fast reset? false
e[36minfoe[39m: [debug] Preparing device for session
e[36minfoe[39m: [debug] Checking whether app is actually present
e[36minfoe[39m: [debug] Checking whether adb is present
e[33mwarne[39m: 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.
e[36minfoe[39m: [debug] Sent shutdown command, waiting for UiAutomator to stop…
e[33mwarne[39m: UiAutomator did not shut down fast enough, calling it gone
e[31merrore[39m: Failed to start an Appium session, err was: Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
e[36minfoe[39m: [debug] Cleaning up android objects
e[36minfoe[39m: [debug] Cleaning up appium session
e[36minfoe[39m: [debug] Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:113:12)
at ChildProcess.exithandler (child_process.js:652:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
e[36minfoe[39m: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)”,“origValue”:“Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.”},“sessionId”:null}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session e[39me[31m500e[39me[90m 7025.336 ms - 342e[39m e[90me[39m
Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9.40 seconds
Build info: version: ‘2.44.0’, revision: ‘76d78cf’, time: ‘2014-10-23 20:02:37’
System info: host: ‘administrators-MacBook-Pro-9.local’, ip: ‘169.254.51.28’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.5’, java.version: ‘1.7.0_60’
Driver info: io.appium.java_client.AppiumDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:95)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:49)
at asd.main(asd.java:41)

Hi I am new to Appium automation and I have setup the environment. However I am getting error

"[31merror[39m: Failed to start an Appium session, err was: Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.

Note : I am able to play the test automation if I start the appium server manually. there was no issue with the Andriod_Home variable.

The issue is only when i start the appium programtically via JAVA code below attached
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js",false);
command.addArgument("–address",false);
command.addArgument(“127.0.0.1”);
command.addArgument("–port",false);
command.addArgument(“4723”);
command.addArgument("–no-reset", false);
command.addArgument("–log");
command.addArgument("/tmp/appiumlogs.log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);

Please help me how you all have resolved this

bash.profile

export ANDROID_HOME=/Users/Gan/Library/Android/sdk/
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/Gan/Library/Android/sdk/tools/:/Users/Gan/Library/Android/sdk/platform-tools/:/Users/Gan/Library/Android/sdk/build-tools/

Hi All,

Did you guys get any solution of this issue. I am also facing same issue please help me for resolving this issue.

Thanks in advance.