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("–port", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
Executor executor = new DefaultExecutor();
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”);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
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:


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!