Android NDK hellojni示例失败

时间:2011-08-23 11:06:27

标签: android java-native-interface android-ndk

我正在尝试在运行Android 2.1的AT91SAM9M10-EKES主板上运行NDK包中的示例 活动失败了。 这是我在logcat中得到的,有人可以指导我吗?

D/AndroidRuntime( 1153): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 1153): CheckJNI is ON
D/AndroidRuntime( 1153): --- registering native functions ---
D/ddm-heap( 1153): Got feature list request
D/AndroidRuntime( 1153): Shutting down VM
D/dalvikvm( 1153): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 1153): DestroyJavaVM shutting VM down
 D/dalvikvm( 1153): HeapWorker thread shutting down
D/dalvikvm( 1153): HeapWorker thread has shut down
D/jdwp    ( 1153): JDWP shutting down net...
I/dalvikvm( 1153): Debugger has detached; object registry had 1 entries
D/dalvikvm( 1153): VM cleaning up
E/AndroidRuntime( 1153): ERROR: thread attach failed
D/dalvikvm( 1153): LinearAlloc 0x0 used 629532 of 5242880 (12%)
D/AndroidRuntime( 1161): 
D/AndroidRuntime( 1161): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 1161): CheckJNI is ON
D/AndroidRuntime( 1161): --- registering native functions ---
D/ddm-heap( 1161): Got feature list request
I/ActivityManager(  767): Starting activity: Intent { act=android.intent.action.MAIN cat=android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.hellojni/.HelloJni }
D/AndroidRuntime( 1161): Shutting down VM
D/dalvikvm( 1161): DestroyJavaVM waiting for non-daemon threads to exit
D/dalvikvm( 1161): DestroyJavaVM shutting VM down
D/dalvikvm( 1161): HeapWorker thread shutting down
D/dalvikvm( 1161): HeapWorker thread has shut down
D/jdwp    ( 1161): JDWP shutting down net...
I/dalvikvm( 1161): Debugger has detached; object registry had 1 entries
D/dalvikvm( 1161): VM cleaning up
E/AndroidRuntime( 1161): ERROR: thread attach failed
D/dalvikvm( 1161): LinearAlloc 0x0 used 639500 of 5242880 (12%)
I/ActivityManager(  767): Start proc com.example.hellojni for activity     com.example.hellojni/.HelloJni: pid=1168 uid=10018 gids={1015}
D/ddm-heap( 1168): Got feature list request
W/dalvikvm( 1168): Exception Ljava/lang/UnsatisfiedLinkError; thrown during     Lcom/example/hellojni/HelloJni;.<clinit>
W/dalvikvm( 1168): Class init failed in newInstance call (Lcom/example/hellojni/HelloJni;)
D/AndroidRuntime( 1168): Shutting down VM
W/dalvikvm( 1168): threadid=3: thread exiting with uncaught exception (group=0x4001b168)
E/AndroidRuntime( 1168): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1168): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 1168):    at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 1168):    at java.lang.Class.newInstance(Class.java:1479)
E/AndroidRuntime( 1168):    at     android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 1168):    at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime( 1168):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 1168):    at   android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 1168):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 1168):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1168):    at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1168):    at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 1168):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1168):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1168):    at      com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 1168):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 1168):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1168): Caused by: java.lang.UnsatisfiedLinkError: Library hello-jni not   found
E/AndroidRuntime( 1168):    at java.lang.Runtime.loadLibrary(Runtime.java:489)
E/AndroidRuntime( 1168):    at java.lang.System.loadLibrary(System.java:557)
E/AndroidRuntime( 1168):    at com.example.hellojni.HelloJni.<clinit>(HelloJni.java:64)
E/AndroidRuntime( 1168):    ... 15 more
I/Process (  767): Sending signal. PID: 1168 SIG: 3
I/dalvikvm( 1168): threadid=7: reacting to signal 3
E/dalvikvm( 1168): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
W/ActivityManager(  767): Launch timeout has expired, giving up wake lock!
W/ActivityManager(  767): Activity idle timeout for HistoryRecord{43d5c310   com.example.hellojni/.HelloJni}
D/dalvikvm(  813): GC freed 301 objects / 14832 bytes in 91ms
I/power   (  767): *** set_screen_state 0
E/power   (  767): Failed setting last user activity: g_error=0
W/ActivityManager(  767): Activity pause timeout for HistoryRecord{43d5c310   com.example.hellojni/.HelloJni}
D/dalvikvm(  873): GC freed 165 objects / 6624 bytes in 81ms

1 个答案:

答案 0 :(得分:2)

你没有构建项目的库(.so)文件,这就是为什么你会收到这个错误,尝试在 android-ndk http://developer.android.com/sdk/ndk/index.html cygwin http://www.cygwin.com/