I am getting the exception"org.openqa.selenium.SessionNotCreatedException"

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;

public class Demo {

AndroidDriver driver =null;
DesiredCapabilities capabilities;
File app = new File("/data/app/com.philips.sleepmapper.root-1/base.apk");

@Test
public void invokeApp() throws MalformedURLException
{
	capabilities = new DesiredCapabilities();
	capabilities.setCapability("automationName", "Appium");
	capabilities.setCapability("paltformName", "Android");
	capabilities.setCapability("platformVersion", "6.0.1");
	capabilities.setCapability("deviceName", "Galaxy S6");
	
	capabilities.setCapability("app", app.getAbsolutePath());
	
	capabilities.setCapability("appPackage", "com.philips.sleepmapper");
	capabilities.setCapability("appactivity", "com.philips.sleepmapper.activity.SplashScreenActivity");
	
	driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	
}

}

When I execute this code it throws an exception, “org.openqa.selenium.SessionNotCreatedException:” A new session could not be created. (Original error: Bad app: C:\data\app\com.philips.sleepmapper.root-1\base.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\data\app\com.philips.sleepmapper.root-1\base.apk’) (WARNING: The server did not provide any stacktrace information)

It looks like you’re trying to specify a filepath to the stored APK on the device. Appium interprets filepaths as if they were pointing to a file on the machine the Appium instance runs on. A Unix filepath simply won’t be interpreted correctly when you’re running on a Windows machine (as suggested by the C:\ part of the filepath Appium ended up searching).

Quick fix: Get rid of the File app= … line, and don’t specify the “app” capability.