Android的JNI:调用的System.loadLibrary()会导致SEGV [英] Android JNI: Calling System.loadLibrary() causes SEGV
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/10079585/application-works-in-debug-run-from-eclipse-but-apk-gives-classnotfoundexce\">Application工作在调试/从Eclipse中运行,但解析包含自定义视图 XML布局时.apk文件给.classNotFoundException
Possible Duplicate:
Application works in debug / run from Eclipse, but .APK gives .classNotFoundException when parsing XML layout that contains a custom View
我是一个现有的NDK编译的库从另一个应用程序重新使用。
I am re-using an existing NDK compiled library from another application.
当我尝试加载使用的System.loadLibrary()库,它SIGSEGV崩溃。
When I try to load the library using System.loadLibrary(), it crashes with SIGSEGV.
简单地说,我这样做:
static {
System.loadLibrary("testlib");
}
我确信该库是好的,因为它是在另一个应用程序(不经修改)被使用。
我还可以加载其他库这种方式没有任何问题。
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.
我是pretty新采用Android / NDK - 是不是我需要小心指定或设置,也许我错过了什么?
I am pretty new to using Android/NDK -- is there something I need to be careful to specify or setup that maybe I missed?
下面就是我看到在日志中:
Here is what I am seeing in the log:
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 >>> com.test.android <<<
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
如果我在模拟器上运行它,它工作正常。
If I run this on the emulator, it works fine.
推荐答案
找到了答案。结果
我的线索是,如果我跑它通过日食将运行正常,当我创建了一个.apk文件只有这个问题。
Found the answer.
My clue was that it would run fine if I ran it through eclipse, and only had this problem when I created a .apk file.
我发现这里的解决方案:<一href=\"http://stackoverflow.com/questions/10079585/application-works-in-debug-run-from-eclipse-but-apk-gives-classnotfoundexce\">Application工作在调试/从Eclipse中运行,但解析包含自定义视图 XML布局时.apk文件给.classNotFoundException
I found the solution here: Application works in debug / run from Eclipse, but .APK gives .classNotFoundException when parsing XML layout that contains a custom View
这篇关于Android的JNI:调用的System.loadLibrary()会导致SEGV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!