Need Help ! "org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session " error on running the script

[TestNG] Running:
C:\Users\user\AppData\Local\Temp\testng-eclipse–1898663871\testng-customsuite.xml

FAILED CONFIGURATION: @BeforeTest setUp
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{appPackage=com.company.remoteOn, appActivity=com.se.appname.views.login.MainLoginActivity, browserName=Android, platformName=Android, deviceName=3a2e249, version=5.1.1}], required capabilities = Capabilities [{}]
Build info: version: ‘unknown’, revision: ‘8c03df6’, time: ‘2017-03-02 09:30:17 -0800’
System info: host: ‘WTIN05200024L’, ip: ‘10.179.201.254’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_60’
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:36)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:92)
at com.schneider.android.app.SimpleAndroidCalcTest.setUp(SimpleAndroidCalcTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.TestRunner.beforeRun(TestRunner.java:656)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)

Trying to run a android app where i get the above error. But I also tried a simple calculator app which worked fine. Its only in our company app we are facing an issue. Any idea on what may be the cause for the issue?

I am using appium 1.6.4 , android version 6.0.1, and using windows 10.

do you mind sharing the code you have used to start driver ?

package pack1;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
public class appiumfirst {
@Test
public void f() throws MalformedURLException{
WebDriver driver;
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability(“deviceName”,“95cffad2”);
cap.setCapability(CapabilityType.BROWSER_NAME, “Android”);
cap.setCapability(CapabilityType.VERSION, “6.0.1”);
cap.setCapability(“platformName”, “Android”);
cap.setCapability(“appPackage”, “com.xxxxxxx.remoteOn.NonProd”);
cap.setCapability(“appActivity”, “com.se.xxxxxx.views.MainActivity”);
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS)
}
}

This is just the basic code written just to check if we can launch our app. We are using a real device not any emulators.

Can you try with

capability.setCapability(MobileCapabilityType.DEVICE_NAME, “XXXXXX”);
capability.setCapability(MobileCapabilityType.PLATFORM_NAME, “XXXXXX”);
capability.setCapability(MobileCapabilityType.PLATFORM_VERSION, “XXXXXX”);
capability.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, “XXXXXX”);
capability.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, “XXXXXX”);

and use AndroidDriver instead of RemoteWebDriver

sure … will try this and let you know

import java.net.URL;
import java.util.concurrent.TimeUnit;

import io.appium.java_client.android.AndroidDriver;

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

public class swipe2 {

AndroidDriver driver;

Dimension size;


@Test

public void setUp() throws Exception {
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("deviceName","9LC6J7CUKJ7DWSVO");
	capabilities.setCapability("platformVesrion","6.0");
	capabilities.setCapability("platformName","Android");
	capabilities.setCapability("appPackage", "com.fortysevendeg.android.swipelistview");
	capabilities.setCapability("appActivity","com.fortysevendeg.android.swipelistview.sample.activities.SwipeListViewExampleActivity");
	driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    size = driver.manage().window().getSize();
	System.out.println(size);

}

@AfterTest
public void quit() {
	driver.quit();
}

}

I am using this code to run the appication but every time i got the same error . anyone help me to out this error .

error message :

Jun 25, 2017 6:22:15 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
FAILED: setUp
org.openqa.selenium.WebDriverException: No command or response codec has been defined. Unable to proceed
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘USER-PC’, ip: ‘192.168.43.206’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_91’
Driver info: driver.version: AppiumDriver
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:154)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:868)
at swipe2.setUp(swipe2.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0

===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0

Getting the same even though the logic works fine.Any solution for this

Try this : https://youtu.be/nnbgLoVWBqU