HELP: Can't get appium working to automate testing android app

I can’t Appium to work automating testing Android app. Here is what i have:

  • Using MAC OS X 10.9.5
  • Appium Version 1.3.4 (Ophiuchus)
  • Tried emulator (Nexus 7, Android 4.4.2 - API Level 19) and Galaxy S5/S4 devices
  • I have JAVA_HOME set in the .bash_profile

Here is how i started the Appium here with the following capabilities:

	capabilities.setCapability("appium-version", "1.3.4");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("platformVersion", "4.4");
	capabilities.setCapability("deviceName", "DeviceName");
	capabilities.setCapability("app", "{path to api file}");
	capabilities.setCapability("appPackage", "com.package.nameformyproject");
	capabilities.setCapability("appActivity", ".MainActivity");
            //capabilities.setCapability("autoLaunch",true);
	capabilities.setCapability("udid","emulator-5554");      //(when tried using emulator)
	wd = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

After i start Appium server, it installs the app and open it in the device or emulator (using Appium GUI, then Pre-launch app is selected). Then when i run tests using eclipse, I am getting the following error in the log:

info: [debug] Condition unmet after 1ms. Timing out. info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“Tried to send command to non-existent Android device, maybe it shut down?”},“sessionId”:“b6a23fce-c24b-4cc7-abb2-973dbf9bddf6”} info: <-- POST /wd/hub/session/b6a23fce-c24b-4cc7-abb2-973dbf9bddf6/element 500 1.923 ms - 242

at the line where it uses xpath to find the element:

WebElement element = appiumDriver.findElement(By.xpath("//android.view.View[1]/android.widget.FrameLayout[2]/android.widget.RelativeLayout[1]/android.widget.FrameLayout[1]"));

Not matter what i try path, className or id, it gives same error. Am i missing somewhere? How do i make it work? Thank you!

is your device detected when you run the following command

adb devices.

if your device is detected then change it to following capabilities.
capabilities.setCapability(“automationName”, “Appium”);
capabilities.setCapability(“platformName”,“Android”);
capabilities.setCapability(“deviceName”,“”);
capabilities.setCapability(“androidPackage”, “com.package.nameformyproject”);
// Here we mention the activity name, which is invoked initially as
// app’s first page.
capabilities.setCapability(“androidActivity”,“.MainActivity”);
capabilities.setCapability(“androidWaitActivity”,“xxxxxxxxxxxxx”);

Thank you for your response. There seems an issue with when autoLaunch set to true. After updating Android SDK and autolaunch set to false resolved my problem. Thank you again.