title: How to hunt down the cause of a Native crash on Android
body: <p>My application is already deployed and works fine on almost all devices that use it, however, on Android 5.1.1, specifically with the LG G3, I'm receiving crash logs for a "Native crash".</p>
  
  <p><code>Native crash at /system/lib64/libc.so</code></p>
  
  <pre><code>*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  Build fingerprint: 'Verizon/zerofltevzw/zerofltevzw:5.1.1/LMY47X/G920VVRU3BOG5:user/release-keys'
  Revision: '10'
  ABI: 'arm64'
  pid: 31341, tid: 31341, name: &lt;companyName&gt;.mobile &gt;&gt;&gt; com.&lt;companyName&gt;.mobile &lt;&lt;&lt;
  signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
  Abort message: 'sart/runtime/class_linker.cc:3135] Check failed: dex_cache.Get() != nullptr Failed to allocate dex cache for /data/app/com.google.android.gms-1/base.apk:classes2.dex'
  x0 0000000000000000 x1 0000000000007a6d x2 0000000000000006 x3 0000007f96649e30
  x4 0000007f96649e30 x5 0000000000000005 x6 0000000000000001 x7 0000000000000020
  x8 0000000000000083 x9 000000000000008a x10 0000007f963d6000 x11 0000000000000001
  x12 0000000000000001 x13 0000007f963d6000 x14 f0ca73d6a9a36950 x15 000000000000000c
  x16 0000007f963d6610 x17 0000007f96376894 x18 0000000000000000 x19 0000007f96649e30
  x20 0000007f9664a0e8 x21 0000007f963dc000 x22 0000000000000001 x23 0000000000000006
  x24 0000007ff97b6020 x25 0000007f928a6000 x26 0000007ff97b6018 x27 0000007f927fd520
  x28 0000007f928a6000 x29 0000007ff97b5ea0 x30 0000007f96338264
  sp 0000007ff97b5ea0 pc 0000007f9637689c pstate 0000000060000000
  
  backtrace:
  #00 pc 000000000005e89c /system/lib64/libc.so (tgkill+8)
  #01 pc 0000000000020260 /system/lib64/libc.so (pthread_kill+160)
  #02 pc 0000000000021794 /system/lib64/libc.so (raise+28)
  #03 pc 000000000001b17c /system/lib64/libc.so (abort+60)
  #04 pc 0000000000310144 /system/lib64/libart.so (art::Runtime::Abort()+300)
  #05 pc 00000000000d52b8 /system/lib64/libart.so (art::LogMessage::~LogMessage()+2684)
  #06 pc 00000000001161f4 /system/lib64/libart.so (art::ClassLinker::RegisterDexFile(art::DexFile const&amp;)+728)
  #07 pc 000000000011d744 /system/lib64/libart.so (art::ClassLinker::FindClassInPathClassLoader(art::ScopedObjectAccessAlreadyRunnable&amp;, art::Thread*, char const*, unsigned long, art::Handle&lt;art::mirror::ClassLoader&gt;)+708)
  #08 pc 000000000011dcdc /system/lib64/libart.so (_ZN3art11ClassLinker9FindClassEPNS_6ThreadEPKcNS_6HandleINS_6mirror11ClassLoaderEEE.part.431+884)
  #09 pc 0000000000122010 /system/lib64/libart.so (art::ClassLinker::ResolveType(art::DexFile const&amp;, unsigned short, art::Handle&lt;art::mirror::DexCache&gt;, art::Handle&lt;art::mirror::ClassLoader&gt;)+244)
  #10 pc 0000000000123588 /system/lib64/libart.so (art::ClassLinker::ResolveMethod(art::DexFile const&amp;, unsigned int, art::Handle&lt;art::mirror::DexCache&gt;, art::Handle&lt;art::mirror::ClassLoader&gt;, art::Handle&lt;art::mirror::ArtMethod&gt;, art::InvokeType)+176)
  #11 pc 00000000003b03b8 /system/lib64/libart.so (art::ClassLinker::ResolveMethod(art::Thread*, unsigned int, art::mirror::ArtMethod**, art::InvokeType)+208)
  #12 pc 00000000003b5554 /system/lib64/libart.so (artQuickResolutionTrampoline+3044)
  #13 pc 00000000000cedd8 /system/lib64/libart.so (art_quick_resolution_trampoline+88)
  #14 pc 0000000002a4bb00 /data/dalvik-cache/arm64/data@app@com.google.android.gms-1@base.apk@classes.dex
  </code></pre>
  
  <p>So far, all I've been able to accomplish is tracking the error code down to being thrown from the <code>ClassLinker::AppendToBootClassPath</code> method in the Android source code. Unfortunately, this didn't help, because I don't know what I can really do to fix the matter.</p>
  
  <p>I've poked around on Google a bit to see if there was any documented processes for debugging this kind of error, but I was unable to find anything meaningful.</p>
  
  <p>What can I do to hunt down the source of this issue?</p>
  
  <p><strong>Edit</strong>: Because this isn't a consistent issue, it has been difficult to try to work through, but from what I've learned recently about the compile process for Android, this appears to be a problem that propagated during compile-time. I think dex may have inadvertently written a bad symbol in the dex cache. When the linker tried to access the token for the method, it bounced an error.</p>
  
  <p>I'm still not sure how to fix this problem, but I'm getting closer to understanding enough to address it.</p>