Getting a SessionNotCreatedException when running Java Program

Hello all. I am currently doing this test on Android with a Mac

I am doing a very basic test where I can run Appium and display an App on the virtual device. However every time I run the Java Program I get this exception thrown:

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired     capabilities = Capabilities [{app=src/bookMyShow-ucb.apk, platformVersion=7.0, platformName=Android,   deviceName=Android Simulator}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Bluecarts-MBP.lan', ip: '', 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_111'
Driver info: driver.version: AndroidDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(
    at org.openqa.selenium.remote.RemoteWebDriver.execute(
    at io.appium.java_client.DefaultGenericMobileDriver.execute(
    at io.appium.java_client.AppiumDriver.execute(
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(
    at io.appium.java_client.AppiumDriver.<init>(
    at io.appium.java_client.AppiumDriver.<init>(
    at desiredcap.test(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    at org.junit.runners.ParentRunner.runLeaf(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$000(
    at org.junit.runners.ParentRunner$2.evaluate(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

Here is my code:

import static org.junit.Assert.*;
import org.junit.Test;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.openqa.selenium.remote.DesiredCapabilities;

public class desiredcap {

public void test() throws MalformedURLException {
	File appDir = new File("src");
	File app = new File(appDir, "bookMyShow-ucb.apk");
	DesiredCapabilities cap = new DesiredCapabilities();
	cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
	cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
	cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Simulator");
	cap.setCapability(MobileCapabilityType.APP, app);
	AndroidDriver ad = new AndroidDriver(new URL(""), cap);		

Thank you all for your help!

What version of appium?

I had trouble with 1.6.3 and using Simulator, and the issue was caused by using a emulator system image that included with Google API. When I used a different image it worked.

Thanks for the reply!

This is on 1.5.3 (App version) I don’t think there is an app version for 1.6.3? That said I will try and use a different image.

This part of the error is interesting.

deviceName=Android Simulator}], required capabilities = Capabilities [{}]

When you open the Android setting on the Appium GUI what is the deviceName you have there?

Device Name in Basic Settings is blank. Could that be the culprit?


I set my deviceName to DeviceName then add the below to my capabilities.

capabilities.setCapability(“deviceName”, “DeviceName”);

When I use a real device I use the below.


So I changed MobileCapabilityType.DEVICE_NAME to just deviceName and still running into the same issue. Does required capabilities have to be filled in as well?

cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “7.0”);

I believe this should be something like 5.0. or 4.4.

It worked! Thank you so much! But for the platform version why is it 4.4? Doesn’t it have to be the android version on the phone?

It’s not the phone version, it’s the hardware version.

When you create the emulator you select a Hardware version then a image.

Make sense?

Ah yes now that does. Thank you for the help!

hi dduphorn,

it doesnt work on my mac. can you help me via team viewer?