Session not created for genymotion emulator---android 4.3, appium 1.3.3 in java eclipse

I need ur help as I need to resolve but I am getting exception when I execute the code in Eclipse:

Code file

package Reusables;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.internal.*;
import io.appium.java_client.android.AndroidDriver;
//import io.appium.java_client.android.

import io.appium.java_client.remote.MobileCapabilityType;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

//import libraries.SetAppium;

public class CopyOfbaseAppium

{
public static Process process;
public static Process process1;

public static String APPIUMSERVERSTART = “/Users/thinksysuser/Desktop/Appium.app/Contents/Resources/node/bin/node /Users/thinksysuser/Desktop/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 192.168.1.13 --bootstrap-port 4724 --no-reset”;
//private static String APPIUMSERVERSTART = “/Applications/Appium 3.app/Contents/Resources/node/bin/node "
// + “/Applications/Appium 3.app/Contents/Resources/node_modules/appium/bin/appium.js”
// + “–address 10.101.23.196 --chromedriver-port 9516”
// + " --bootstrap-port 4723 --no-reset --local-timezone”;

public static String GenyMotionStart = “/Applications/Genymotion.app/Contents/MacOS/player --vm-name GoogleNexus7-4.3-API18-800_1280”;
private static String URL; //= “http://127.0.0.1:4000/wd/hub”;
//public static final HttpClient client = HttpClients.createDefault();
//public static final JsonParser parser = new JsonParser();
File classpathRoot = new File(System.getProperty(“user.dir”));
File appDir = new File(classpathRoot, “//Desktop//”);
File app = new File(appDir, “”);
public static DesiredCapabilities capabilities = new DesiredCapabilities();
//public static AppiumDriver driver;
public static AndroidDriver driver1;

public static void main(String args[]) throws IOException, InterruptedException, SessionNotCreatedException
{

stopAppiumServer();
startgenymotion();
Thread.sleep(25000);

startAppiumServer();
Thread.sleep(20000);

setCapabilities();


/*finally
{
	stopAppiumServer(); 
}*/

}

public static void startgenymotion() throws IOException, InterruptedException
{
Runtime runtime = Runtime.getRuntime();
process1 = runtime.exec(GenyMotionStart);
System.out.println(Runtime.getRuntime().exec(GenyMotionStart) !=null);
Thread.sleep(5000);
if (process1 != null)
{
System.out.println(“GenyM server started”);
}
}

public static void startAppiumServer() throws IOException
{
Runtime runtime = Runtime.getRuntime();
process = runtime.exec(APPIUMSERVERSTART);
// System.out.println(Runtime.getRuntime().exec(APPIUMSERVERSTART) !=null);
// Thread.sleep(5000);
if (process != null)
{
System.out.println(“Appium server started”);
}
//System.out.println(process.getOutputStream().toString());

}

public static void setCapabilities() throws MalformedURLException, InterruptedException
{
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “Android Emulator”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “GoogleNexus7-4.3-API18-800_1280”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.3”);
capabilities.setCapability(MobileCapabilityType.APP, “/Users/thinksysuser/Desktop/ma.com.apk”);

	driver1 = new AndroidDriver(new URL("http://192.168.1.13:4723/wd/hub/"), capabilities);
}

public static  void stopAppiumServer() throws IOException 
{
String[] command ={"/usr/bin/killall","-KILL","node"};
Runtime.getRuntime().exec(command);
System.out.println("Appium server stop");
}

}

Terminal command:
open .bash_profile

export ANDROID_HOME=/Users/thinksysuser/Documents/android_sdk
export PATH=$PATH:$ANDROID_HOME/tools

Log file

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: 7.28 seconds
Build info: version: ‘2.44.0’, revision: ‘76d78cf’, time: ‘2014-10-23 20:03:00’
System
info: host: ‘thinksyusersmbp.local.lan’, ip: ‘192.168.1.13’, os.name:
‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.5’, java.version:
‘1.7.0_67’
Driver info: io.appium.java_client.android.AndroidDriver
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:176)
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:107)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:40)
at Reusables.CopyOfbaseAppium.setCapabilities(CopyOfbaseAppium.java:122)
at Reusables.CopyOfbaseAppium.main(CopyOfbaseAppium.java:58)

Hi
Am facing a similar issue. But I think you have a set a wrong capability. Please change to the following:
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Android Emulator”);
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 120);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, 17);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Hope that helps!

Could you also check your appium console for error/exception messages? In my case, I was able to resolve it based on the error message I saw in the appium console. Please copy/paste the error message you are seeing there, then I’ll be able to help you.

Hi Thanks,
The issue I am facing is only due to start APPIUM from inside the code.

So for now, I have commented that code and everythign is working fine.

Again I am thankfull for ur support

Thank,
Ashish Bajpai