title: Appium and Virtual Android Device desired capabilities: SessionNotCreatedException error
body: <p>So I am trying to write an automation test script for an android app running inside an Android Emulator (avd) but I am getting the error below in Appium logs:</p>
  
  <pre><code>[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect.
   We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities
  ","capabilities","sessionId","id","sessionId","id"]} and you sent ["desiredCapab
  ilities","requiredCapabilities","capabilities","alwaysMatch","firstMatch"]
  </code></pre>
  
  <p>My setup is:</p>
  
  <ol>
  <li>Android Studio 162 (w/ sdk, note that this latest version does not include the 'android' command anymore, the creation of the android virtual device is done through Tools > Android > AVD Manager)</li>
  <li>IntelliJ 2016.3.5 (for writing the automation test script)</li>
  <li>selenium-java 3.3.0 (required jar)</li>
  <li>appium java client 4.1.2 (required jar)</li>
  <li>appium server 1.6.3 (executed in nodejs cli by running 'appium')</li>
  <li>Android Virtual Device version 5.1 Lollipop</li>
  </ol>
  
  <p>Running 'adb devices' command in cmd gives me</p>
  
  <pre><code>List of devices attached
  emulator-5554   device
  </code></pre>
  
  <p>Desired capabilities setting is</p>
  
  <pre><code>@BeforeClass
  public void setUp() throws MalformedURLException{
      DesiredCapabilities capabilities = new DesiredCapabilities();
  
      capabilities.setCapability("platformName","Android");
      capabilities.setCapability("platformVersion","5.1");
      capabilities.setCapability("deviceName","emulator-5554");
      capabilities.setCapability("app", path_to_apk);
      driver =  new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  
  }
  </code></pre>
  
  <p>IDE error output when running the test:</p>
  
  <pre><code>org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=src//main//resources//test.apk, platformVersion=5.1, platformName=Android, deviceName=emulator-5554}], required capabilities = Capabilities [{}]
  Build info: version: '3.3.0', revision: 'b526bd5b41', time: '2017-03-07 19:26:04 +0000'
  </code></pre>
  
  <p>I am stuck at this point and don't know what to do.</p>