title: Appium: A new session could not be created
body: <p>Before posting this question I went to these questions on Stackoverflow and other forums:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/22248328/a-new-session-could-not-be-created-original-error-instruments-crashed-on-star">A new session could not be created. (Original error: Instruments crashed on startup)</a></li>
  <li><a href="https://stackoverflow.com/questions/24626529/appium-error-a-new-session-could-not-be-created-original-error-did-not-get">Appium Error : A new session could not be created. (Original error: Did not get session redirect from Chromedriver)</a></li>
  <li><p><a href="https://github.com/appium/appium/issues/2981" rel="nofollow noreferrer">https://github.com/appium/appium/issues/2981</a>
  <br>and did few changes in my code below:<p>
  Code:</p>
  
  <pre><code>package test.appium;
  
  import io.appium.java_client.AppiumDriver;
  
  import java.io.File;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.concurrent.TimeUnit;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.remote.CapabilityType;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.testng.annotations.Test;
  
  public class WordPad {
  WebDriver dr;
  
  @Test
  public void testApp() throws MalformedURLException, InterruptedException {
      String apkpath = "D:\\apkdump\\blackcarbon.wordpad.apk";
      File app = new File (apkpath);
      DesiredCapabilities capabilities= new DesiredCapabilities();
      capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
      capabilities.setCapability("deviceName","TestOneAdb1");
      capabilities.setCapability("appium-version", "1.2.4.1");
      capabilities.setCapability("platformName","Android");
      capabilities.setCapability("app",app.getAbsolutePath());
      capabilities.setCapability("appPackage", "com.wordpad");
      capabilities.setCapability("appActivity", "com.wordpad.Main");
      dr = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);                    
      dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      dr.quit();      
  }   
  }
  </code></pre>
  
  <p>but I am still getting the error:</p>
  
  <blockquote>
    <p>info: [debug] UiAutomator shut down normally</p>
    
    <p>error: Failed to start an Appium session, err was: Error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity</p>
    
    <p>info: [debug] Cleaning up android objects</p>
    
    <p>info: [debug] Cleaning up appium session</p>
    
    <p>info: [debug] Error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity</p>
  
  <pre><code>at null.&lt;anonymous&gt; (D:\MobileTesting\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1143:21)
  
  at null.&lt;anonymous&gt; (D:\MobileTesting\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:172:9)
  
  at ChildProcess.exithandler (child_process.js:635:7)
  
  at ChildProcess.EventEmitter.emit (events.js:98:17)
  
  at maybeClose (child_process.js:743:16)
  
  at Process.ChildProcess._handle.onexit (child_process.js:810:5)
  </code></pre>
    
    <p>info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity)","origValue":"Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity"},"sessionId":null}</p>
    
    <p>info: [37m&lt;-- POST /wd/hub/session [39m[31m500[39m[90m 51290.254 ms - 346[39m [90m[39m
    What I tried:</p>
    
    <ol>
    <li>Install app manually on emulator and check if its working: It was working</li>
    <li>Once the app is installed via code:  I can play with manually on emulator, it works perfectly fine. </li>
    <li>Downgrade <code>Appium</code> version from latest <code>1.1.0</code> tried but same error</li>
    <li>Specify <code>Appium</code>version capabilities in code, tried but still same error.</li>
    </ol>
  </blockquote></li>
  </ol>
  
  <p>Let me know what I am missing, how can I launch app after installation?</p>