title: Application gets crashes when executing automation test for android application using Appium
body: <p>I am trying to automate some mobile application tests running on Android device through <strong>Appium</strong>, <strong>Selenium framework</strong>. I've setup my test classes in <strong>Selenium</strong> and trying to start android driver using below desired capabilities. My <strong>Appium</strong> version is 1.4.16.1</p>
  
  <pre><code>public static void initialize() {
      // Created object of DesiredCapabilities class.
      DesiredCapabilities capabilities = new DesiredCapabilities();
  
      // Set android deviceName desired capability. Set your device name.
      capabilities.setCapability("deviceName", "03157df388c7b934");
  
      // Set BROWSER_NAME desired capability. It's Android in our case
      // here.
      capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
  
      // Set android VERSION desired capability. Set your mobile device's
      // OS
      // version.
      capabilities.setCapability(CapabilityType.VERSION, "6.0.1");
  
      // Set android platformName desired capability. It's Android in our
      // case
      // here.
      capabilities.setCapability("platformName", "Android");
  
      // Set android appPackage desired capability. It is
      // com.android.calculator2 for calculator application.
      // Set your application's appPackage if you are using any other app.
      capabilities.setCapability("appPackage","com.pnc.ecommerce.mobile.finder");
      capabilities.setCapability("appActivity", "com.fisglobal.lfi.pnc.ui.MainActivity");
  
      try {
              driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                  capabilities);
  
              driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
          } catch (Exception e) {
              e.printStackTrace();
              throw new RuntimeException("Driver initialization failed", e);
          }
  }
  </code></pre>
  
  <p>When I run the test on real Samsung device, application is opened and then get crashed as soon as it opens with a message  <code>PNC Stopped..</code>, my testing app is <code>PNC mobile app</code></p>
  
  <p>When I check the logs in Appium desktop console, I see below stuffs :</p>
  
  <pre><code> &lt;&lt; info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
  
  info: Appium REST http interface listener started on 127.0.0.1:4723
  info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
  info: Console LogLevel: debug
  Killed Node Server.
  Appium server process ended
  Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
  info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
  info: Appium REST http interface listener started on 127.0.0.1:4723
  info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
  info: Console LogLevel: debug
  info: --&gt; POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.pnc.ecommerce.mobile.finder","appActivity":"com.fisglobal.lfi.pnc.ui.MainActivity","browserName":"Android","platformName":"Android","deviceName":"03157df388c7b934","version":"6.0.1"}}
  info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
  info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
  info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
  info: [debug] Creating new appium session 4950142d-270c-433f-ba7f-c6fdea58f76a
  info: Starting android appium
  info: [debug] Getting Java version
  info: Java version is: 1.8.0_131
  info: [debug] Checking whether adb is present
  info: [debug] Using adb from C:\Android\android-sdk-windows\platform-tools\adb.exe
  warn: No app capability, can't parse package/activity
  info: [debug] Using fast reset? true
  info: [debug] Preparing device for session
  info: [debug] Not checking whether app is present since we are assuming it's already on the device
  info: Retrieving device
  info: [debug] Trying to find a connected android device
  info: [debug] Getting connected devices...
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe devices
  info: [debug] 1 device(s) connected
  info: Found device 03157df388c7b934
  info: [debug] Setting device id to 03157df388c7b934
  info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 wait-for-device
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "echo 'ready'"
  info: [debug] Starting logcat capture
  info: [debug] Getting device API level
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "getprop ro.build.version.sdk"
  info: [debug] Device is at API Level 23
  info: Device API level is: 23
  info: [debug] Extracting strings for language: default
  info: [debug] Apk doesn't exist locally
  info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "rm -rf /data/local/tmp/strings.json"
  info: [debug] Not uninstalling app since server not started with --full-reset
  info: [debug] Skipping install since we launched with a package instead of an app path
  info: [debug] Forwarding system:4724 to device:4724
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 forward tcp:4724 tcp:4724
  info: [debug] Pushing appium bootstrap to device...
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
  info: [debug] Pushing settings apk to device...
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
  info: [debug] Pushing unlock helper app to device...
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
  info: Starting App
  info: [debug] Attempting to kill all 'uiautomator' processes
  info: [debug] Getting all processes with 'uiautomator'
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "ps 'uiautomator'"
  info: [debug] No matching processes found
  info: [debug] Running bootstrap
  info: [debug] spawning: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.pnc.ecommerce.mobile.finder -e disableAndroidWatchers false
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
  info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
  info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
  info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
  info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
  info: [debug] [BOOTSTRAP] [debug] Loading json...
  info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
  info: [debug] Waking up device if it's not alive
  info: [debug] Pushing command to appium work queue: ["wake",{}]
  info: [debug] [BOOTSTRAP] [debug] Client connected
  info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
  info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
  info: [debug] [BOOTSTRAP] [debug] Got command action: wake
  info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "dumpsys window"
  info: [debug] Screen already unlocked, continuing.
  info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
  info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
  info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
  info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
  info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"}
  info: [debug] dataDir set to: /data/local/tmp
  info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
  info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
  info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
  info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
  info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false}
  info: [debug] Getting device API level
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "getprop ro.build.version.sdk"
  info: [debug] Device is at API Level 23
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.pnc.ecommerce.mobile.finder/com.fisglobal.lfi.pnc.ui.MainActivity"
  info: [debug] Waiting for pkg "com.pnc.ecommerce.mobile.finder" and activity "com.fisglobal.lfi.pnc.ui.MainActivity" to be focused
  info: [debug] Getting focused package and activity
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "dumpsys window windows"
  info: [debug] executing cmd: C:\Android\android-sdk-windows\platform-tools\adb.exe -s 03157df388c7b934 shell "getprop ro.build.version.release"
  info: [debug] Device is at release version 6.0.1
  info: [debug] Device launched! Ready for commands
  info: [debug] Setting command timeout to the default of 60 secs
  info: [debug] Appium session started with sessionId 4950142d-270c-433f-ba7f-c6fdea58f76a
  info: &lt;-- POST /wd/hub/session 303 5351.163 ms - 74 
  info: --&gt; GET /wd/hub/session/4950142d-270c-433f-ba7f-c6fdea58f76a {}
  info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.pnc.ecommerce.mobile.finder","appActivity":"com.fisglobal.lfi.pnc.ui.MainActivity","browserName":"Android","platformName":"Android","deviceName":"03157df388c7b934","version":"6.0.1"},"appPackage":"com.pnc.ecommerce.mobile.finder","appActivity":"com.fisglobal.lfi.pnc.ui.MainActivity","platformName":"Android","deviceName":"03157df388c7b934","version":"6.0.1"},"sessionId":"4950142d-270c-433f-ba7f-c6fdea58f76a"}
  info: &lt;-- GET /wd/hub/session/4950142d-270c-433f-ba7f-c6fdea58f76a 200 3.558 ms - 705 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.pnc.ecommerce.mobile.finder","appActivity":"com.fisglobal.lfi.pnc.ui.MainActivity","browserName":"Android","platformName":"Android","deviceName":"03157df388c7b934","version":"6.0.1"},"appPackage":"com.pnc.ecommerce.mobile.finder","appActivity":"com.fisglobal.lfi.pnc.ui.MainActivity","platformName":"Android","deviceName":"03157df388c7b934","version":"6.0.1"},"sessionId":"4950142d-270c-433f-ba7f-c6fdea58f76a"}
  Killed Node Server.
  Appium server process ended &gt;&gt;
  </code></pre>
  
  <p>Please help me to sort out this issue</p>