Unable to find adb when launching Appium server programmatically

I’ve been trying to get the Appium server to run programmatically and was successful with iOS projects but am having some difficulty with Android. I am running a native app on Android and the project specs are below:

  • Appium 1.3.7
  • Eclipse IDE (Luna)
  • Java bindings

When I launch the server I immediately get the error that it cannot find adb. When I run the doctor diagnostics, it finds adb just fine. ANDORID_HOME is set to the proper sdk folder and a direct line to adb is also included in my PATH. One thing to note is that I have both Eclipse and Android Studio installed on my machine. The Android SDK is coming from the Android Studio install, but I am running my project out of Eclipse at the moment and pointing to the sdk installed from Android Studio. Curious if anyone may have a suggestion outside of migrating projects to Android Studio (that is my last resort). Code snippet to launch Appium is below (this code does successfully start an iOS project).

CommandLine command = new CommandLine("/usr/local/bin/node");
command.addArgument("/usr/local/bin/appium", false);
command.addArgument("–address", false);
command.addArgument(“127.0.0.1”);
command.addArgument("–port", false);
command.addArgument(“4723”);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
Executor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);

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

CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“C:\AppiumForWindows-1.2.4.1\Appium\node.exe”);
command.addArgument(“C:\AppiumForWindows1.2.4.\Appium\node_modules\appium\bin\appium.js”);
command.addArgument("–address");
command.addArgument(“127.0.0.1”);
command.addArgument("–port");
command.addArgument(“4723”);
command.addArgument("–no-reset");
command.addArgument("–log");
command.addArgument(“D:\appiumLogs.txt”);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);

Sorry, forgot to add that I am working off of an OSX machine (10.10.2). The above won’t work for my purposes. What I really need to figure out is why when I run appium-doctor it finds adb, but when I start the server from Eclipse, it doesn’t.

I Googled for you & found a couple of things that might help:

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_run_env.htm

Do these help? I think the first one still applies to Luna.

Added the env variable to the Run Configuration and it’s working like a charm. As soon as I read Run Configuration and environment variables it all made sense. Thanks, I really appreciate it!