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
As mentioned, JNI_OnLoad isn't necessary. Here's your problem:
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
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.
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 ... >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With