title: Appium: custom android app keeps crashing on launch
body: <p>Have a problem where all of a sudden a previously working appium based android app selenium test has stopped working as it did (consistently successful).</p>
  
  <p>The issue is specifically to do with the launch of the app by appium (the app always launches when opened with physical user input..). Basically the app launches, the loading screen appears and then it crashes. This happens most of the time but not always. I've found it usually works fine initially after restarting the phone. However, it'll crash on subsequent runs. </p>
  
  <p>Any assistance would be much appreciated. Tried many things/searching online already but it's all been to of no avail..</p>
  
  <p>Here's the appium output:</p>
  
  <pre><code>[AndroidDriver] Parsed pid: '27608' pkg: 'com.dedsert.betbright.uat' from
  [AndroidDriver]     USER      PID   PPID  VSIZE  RSS   WCHAN              PC  NAME
  [AndroidDriver]     u0_a236   27608 4736  3621124 393160          0 0000000000 R com.dedsert.betbright.uat
  [AndroidDriver] Returning process name: 'com.dedsert.betbright.uat'
  [AndroidDriver] Found webviews: ["WEBVIEW_com.dedsert.betbright.uat"]
  [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.dedsert.betbright.uat"]
  [MJSONWP] Responding to client with driver.setContext() result: null
  [HTTP] &lt;-- POST /wd/hub/session/a9457315-d657-4fd1-bdf0-36fe5d76b3c5/context 200 245 ms - 76 
  [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_RESULT: shortMsg=java.lang.StackOverflowError
  [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_RESULT: longMsg=stack size 1037KB
  [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_CODE: 0
  [UiAutomator] UiAutomator exited unexpectedly with code 4294967295, signal null
  [UiAutomator] Moving to state 'stopped'
  [AndroidDriver] Shutting down Android driver
  [Appium] Closing session, cause was 'UiAUtomator shut down unexpectedly'
  [Appium] Removing session a9457315-d657-4fd1-bdf0-36fe5d76b3c5 from our master session list
  [ADB] Getting connected devices...
  [ADB] 1 device(s) connected
  [ADB] Running 'C:\Users\kroring\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce051715c336451002","shell","am","force-stop","com.dedsert.betbright.uat"]
  [ADB] Pressing the HOME button
  [ADB] Getting connected devices...
  [ADB] 1 device(s) connected
  [ADB] Running 'C:\Users\kroring\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce051715c336451002","shell","input","keyevent",3]
  [AndroidBootstrap] Cannot shut down Android bootstrap; it has already shut down
  [Logcat] Stopping logcat capture
  [ADB] Getting connected devices...
  [ADB] 1 device(s) connected
  [ADB] Running 'C:\Users\kroring\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","ce051715c336451002","shell","am","force-stop","io.appium.unlock"]
  [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
  [HTTP] --&gt; POST /wd/hub/session/a9457315-d657-4fd1-bdf0-36fe5d76b3c5/context {"name":"WEBVIEW_com.dedsert.betbright.uat"}
  [HTTP] &lt;-- POST /wd/hub/session/a9457315-d657-4fd1-bdf0-36fe5d76b3c5/context 404 1 ms - 131 
  </code></pre>
  
  <p>Not a whole lot to be seen on the IntelliJ side - did spot this in the stacktrace given:</p>
  
  <pre><code>org.openqa.selenium.remote.SessionNotFoundException: A session is either terminated or not started (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 5 milliseconds
  </code></pre>