Getting error while invoking browser on Android device Appium 1.5.3 from java code

I am trying to automate a website on my Android mobile using Java code.
I am having Appium 1.5.3.
My mobile is Mi 4i Android version 5.0.2.

When I run the code the browser is opened on mobile, but it immediately closes giving the following exception -

org.openqa.selenium.remote.SessionNotFoundException: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: ‘2.46.0’, revision: ‘87c69e2’, time: ‘2015-06-04 16:17:10’
System info: host: ‘TCGs-Mac-mini.local’, ip: ‘192.168.2.1’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_102’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{networkConnectionEnabled=true, noReset=true, warnings={}, databaseEnabled=false, deviceName=xxxxxxx, platform=LINUX, deviceUDID=xxxxxxx, desired={noReset=true, newCommandTimeout=300000, automationName=Appium, browserName=Chrome, platformName=Android, device=Android, deviceName=Android}, newCommandTimeout=300000, platformVersion=5.0.2, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, browserName=Chrome, javascriptEnabled=true, platformName=Android, device=Android}]
Session ID: ad6b106d-d515-47cb-bd7b-f80a24ba47f0
17:58:21,071 ERROR Keyword:100 - InvokeApp :threw error(no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: ‘2.46.0’, revision: ‘87c69e2’, time: ‘2015-06-04 16:17:10’
System info: host: ‘TCGs-Mac-mini.local’, ip: ‘192.xxx.xxx.1’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_102’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{networkConnectionEnabled=true, noReset=true, warnings={}, databaseEnabled=false, deviceName=xxxxxxx, platform=LINUX, deviceUDID=xxxxxxx, desired={noReset=true, newCommandTimeout=300000, automationName=Appium, browserName=Chrome, platformName=Android, device=Android, deviceName=Android}, newCommandTimeout=300000, platformVersion=5.0.2, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, browserName=Chrome, javascriptEnabled=true, platformName=Android, device=Android}]
Session ID: ad6b106d-d515-47cb-bd7b-f80a24ba47f0)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:176)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)
at com.lntinfotech.fast.ios.keywords.impl.InvokeApp.instantiateWebDriver(InvokeApp.java:380)
at com.lntinfotech.fast.ios.keywords.impl.InvokeApp.callInvokeApp(InvokeApp.java:88)
at com.lntinfotech.fast.ios.keywords.impl.InvokeApp.execute(InvokeApp.java:74)
at com.lntinfotech.fast.common.keywords.Keyword.processKeyword(Keyword.java:130)
at com.lntinfotech.fast.common.processFiles.ProcessKDT.process(ProcessKDT.java:143)
at com.lntinfotech.fast.common.processFiles.CFProcessHelper.executeKDT(CFProcessHelper.java:145)
at com.lntinfotech.fast.common.processFiles.CFProcessHelper.executeKDT(CFProcessHelper.java:95)
at com.lntinfotech.fast.common.processFiles.CFProcessHelper.execute(CFProcessHelper.java:53)
at com.lntinfotech.fast.processFiles.ProcessControlFile.process(ProcessControlFile.java:196)
at com.lntinfotech.fast.FASTCore.execute(FASTCore.java:95)
at com.lntinfotech.fast.FASTJavaMain.startFASTExecution(FASTJavaMain.java:74)
at com.lntinfotech.fast.FASTJavaMain.main(FASTJavaMain.java:28)

Kindly provide solution

@Gaurav solution - start Appium server before starting test :slight_smile:

  1. How you start Appium server?
  2. What url you set when you open driver?

@Aleksei I am starting the Appium server from java code. It is starting properly.
I am trying to invoke www.amazon.com from browser.
But browser is closed before invoking the website and the above mentioned exception occurs