title: Android JNI: Calling System.loadLibrary() causes SEGV
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10079585/application-works-in-debug-run-from-eclipse-but-apk-gives-classnotfoundexce">Application works in debug / run from Eclipse, but .APK gives .classNotFoundException when parsing XML layout that contains a custom View</a>  </p>
  </blockquote>
  
  
  
  <p>I am re-using an existing NDK compiled library from another application.</p>
  
  <p>When I try to load the library using System.loadLibrary(), it crashes with SIGSEGV.</p>
  
  <p>Simply, I am doing this:</p>
  
  <pre><code>  static {
          System.loadLibrary("testlib");
        }
  </code></pre>
  
  <p>I am confident the library is good, as it is being used in another application (without modification).
  I can also load other libraries this way without any issue.</p>
  
  <p>I am pretty new to using Android/NDK -- is there something I need to be careful to specify or setup that maybe I missed?  </p>
  
  <p>Here is what I am seeing in the log:</p>
  
  <pre><code>04-17 09:33:37.725  6100  6100 D dalvikvm: Trying to load lib /data/data/com.test.android/lib/libtestlib.so 0x4051617
  0
  04-17 09:33:37.733  6100  6100 D dalvikvm: Added shared lib /data/data/com.test.android/lib/libtestlib.so 0x40516170
  04-17 09:33:37.733  6108  6108 I DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  04-17 09:33:37.733  6108  6108 I DEBUG   : Build fingerprint: 'verizon/venus2_vzw/cdma_venus2:2.3.4/4.5.1-110-VNS-35/120113:user/release-keys'
  04-17 09:33:37.733  6108  6108 I DEBUG   : pid: 6100, tid: 6100  &gt;&gt;&gt; com.test.android &lt;&lt;&lt;
  04-17 09:33:37.733  6108  6108 I DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000018
  04-17 09:33:37.733  6108  6108 I DEBUG   :  r0 00000005  r1 aca83d13  r2 000415a6  r3 81db5c4c
  04-17 09:33:37.733  6108  6108 I DEBUG   :  r4 00000000  r5 00000000  r6 81db5c4c  r7 81db5c40
  04-17 09:33:37.733  6108  6108 I DEBUG   :  r8 0000cec8  r9 81c8734d  10 002b1284  fp 00000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  ip fffffe8c  sp bef91e48  lr aca6661b  pc aca45c0e  cpsr 20000070
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d0  643a64696f72646e  d1  6472656767756265
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d2  81dbd63081dc20c8  d3  81dc30a081c84481
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d4  81c844b981db6ccc  d5  81dc20b481dc209c
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d6  81dc20cc81c844ad  d7  81c844a181dbb618
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d8  0000000000000000  d9  0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d10 0000000000000000  d11 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d12 0000000000000000  d13 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d14 0000000000000000  d15 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d16 bef91b68405515a8  d17 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d18 0707070703030303  d19 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d20 0100010001000100  d21 0100010001000100
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d22 0000000000000000  d23 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d24 0000000000000000  d25 0000000000000000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d26 0100010001000100  d27 0100010001000100
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d28 0100010001000100  d29 0100010001000100
  04-17 09:33:37.733  6108  6108 I DEBUG   :  d30 00c7000000c10000  d31 00d3000000cd0000
  04-17 09:33:37.733  6108  6108 I DEBUG   :  scr 20000012
  </code></pre>
  
  <p>If I run this on the emulator, it works fine.</p>