Hi, you are more likely to get help on android-ndk.
On Wed, Sep 9, 2009 at 9:36 PM, pink 444 <[email protected]> wrote:
>
> hai folks,
>
> In Android , Native code is written as follows.
>
> JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject
> obj)
> {
> printf("THIS IS TEST");
> }
>
> JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
> {
> JNIEnv *env;
> JNINativeMethod meth;
> jclass k;
> jint r;
>
> r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
> k = (*env)->FindClass (env, "com.android.Test.show");
>
>
> meth.name = "show";
> meth.signature = "()V";
> meth.fnPtr = Java_com.android.Test.show;
> r = (*env)->RegisterNatives (env, k, &meth, 1);
> return JNI_VERSION_1_4;
>
>
>
> }
>
>
> JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved)
> {
> JNIEnv *env;
> jclass k;
> jint r;
> r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
> k = (*env)->FindClass (env, "com.android.Test.show");
> (*env)->UnregisterNatives(env, k);
>
>
> }
>
>
> While executing on Android the following messages are obeserved in adb
> logcat.
>
> JNI ( 524): Trying to load jni .so
> I/System.out( 524): /system/lib
> D/dalvikvm( 524): Trying to load lib /data/libjnilibs.so 0x433f22d0
> D/dalvikvm( 524): Added shared lib /data/libjnilibs.so 0x433f22d0
> I/ActivityManager( 50): Displayed activity
> com.android.helloactivity
>
> But "THIS IS TEST" is not being displayed, which is displayed in
> native code.
>
> There are no errors regarding loading shared library and calling
> native code.Then why is the message is not displayed in logging.
>
> Am i doing any mistake.If JNI_OnLoad and JNI_OnUnLoad are not
> implemented i am getting errors in Logging.If i do as above i not
> getting that native code message.
>
>
> Any help would be appreciated highly.
>
> Regards,
> -Siva.
> >
>
--
Dianne Hackborn
Android framework engineer
[email protected]
Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---