title: Catching exceptions thrown from native code running on Android
body: <p>The project I'm currently working on requires me to code up the android portion of a cross platform program implementation.</p>
  
  <p>A core set of functionality is built and included in my app through <code>android-ndk</code>. I've found that any exception/crash which happens in the native code is only reported now and again at best. When an error occurs I get one of the following behaviours:</p>
  
  <ul>
  <li>A stacktrace / memory dump occurs and is written to the log file. The program disappears (no indication is given on the device as to why suddenly the app is no longer there).</li>
  <li>No stacktrace / dump or other indication is given that the native code has crashed. The program disappears.</li>
  <li>The java code crashes with a <code>NullPointerException</code> (usually in the same place per native code exception which is a massive pain). Usually causing me to spend quite a while trying to debug why the Java code has thrown an error only to discover the Java code is fine &amp; the native code error has been entirely masked.</li>
  </ul>
  
  <p>I can't seem to find any way to "insulate" my code against errors which occur in native code. Try/catch statements are resoundingly ignored. Apart from when my code is fingered as the culprit I don't even get a chance to warn the user than an error has occurred.</p>
  
  <p>Can someone please help me out as to how to respond to the situation of crashing native code?</p>