无JNI_Onload()发现VM关闭 [英] No JNI_Onload() found and VM shutting down

查看:155
本文介绍了无JNI_Onload()发现VM关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid,
我跟着链接上的说明 http://marakana.com/forums/android/examples/ 49.html ,以创建一个使用NDK的基本应用。

I am new to Android , I followed the instructions on the link http://marakana.com/forums/android/examples/49.html to create the basic application using NDK.

我跟着那些步骤完全相同。我还创建了共享库。
当我运行应用程序,显示目录下载以下错误:

I followed those steps exactly. I also created the shared library. When I run the application, CatLog shows the following errors:

Trying to load lib /data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18
01-30 04:50:58.856: D/dalvikvm(586): Added shared lib
                    /data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18
01-30 04:50:58.856: D/dalvikvm(586): No JNI_OnLoad found in 
                    /data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18,
                    skipping init
01-30 04:50:58.866: D/AndroidRuntime(586): Shutting down VM
01-30 04:50:58.866: W/dalvikvm(586): threadid=1: thread exiting with uncaught 
                    exception (group=0x409c01f8)
01-30 04:50:58.896: E/AndroidRuntime(586): FATAL EXCEPTION: main
01-30 04:50:58.896: E/AndroidRuntime(586): java.lang.RuntimeException:
                    Unable to instantiate activity ComponentInfo
                    {com.example.NDKDemo/com.example.NDKDemo.NativeLib}:
                    java.lang.ClassCastException:
                    com.example.NDKDemo.NativeLib cannot be cast to android.app.Activity


推荐答案

如前所述,JNI_OnLoad是没有必要的。这是你的问题:

As mentioned, JNI_OnLoad isn't necessary. Here's your problem:

无法实例活动ComponentInfo
                      {com.example.NDKDemo / com.example.NDKDemo.NativeLib}:
                      java.lang.ClassCastException:
                      com.example.NDKDemo.NativeLib不能转换为android.app.Activity

Unable to instantiate activity ComponentInfo {com.example.NDKDemo/com.example.NDKDemo.NativeLib}: java.lang.ClassCastException: com.example.NDKDemo.NativeLib cannot be cast to android.app.Activity

您的错误甚至不是NDK的问题,它看起来像:您的类com.example.NDKDemo.NativeLib不能转换为android.app.Activity

Your bug isn't even an NDK issue, it looks like: Your class com.example.NDKDemo.NativeLib can't be cast to android.app.Activity.

您在AndroidManifest.xml中列出的类是从派生的活动之一。如果你创建了一个NDKDemo类比如上例中,那么这就是你的活动,你应该在AndroidManifest.xml命名为:

The class you list in AndroidManifest.xml is the one that derives from Activity. If you created an NDKDemo class like in the example, then that's your activity, and you should name it in AndroidManifest.xml:

<activity android:name="NDKDemo" ... other options ... >

这篇关于无JNI_Onload()发现VM关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆