Native code is being called successfully but not executed properly

by pink 444 » Thu, 10 Sep 2009 12:37:42 GMT

Sponsored Links
 hai folks,

            In Android , Native code is written as follows.

JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject
      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, "");
 = "show";
        meth.signature = "()V";
        meth.fnPtr =;
        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, "");
        (*env)->UnregisterNatives(env, k);


While executing on Android the following messages are obeserved in adb

JNI     (  524): Trying to load jni .so
I/System.out(  524): /system/lib
D/dalvikvm(  524): Trying to load lib /data/ 0x433f22d0
D/dalvikvm(  524): Added shared lib /data/ 0x433f22d0
I/ActivityManager(   50): Displayed activity

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.


Other Threads

1. just the news we are waiting for , G-Phone to be launched next week

According to the news G-Phone to be launched next week named dream,
please see the link below for more details

sukanta maikap

2. Speech Library Confirmation (Urgent)

Hi there,
I am a final year, under-graduate student from India, i intend to
develop my Final Year Project on the Android platform but, i am in a
fix right now. I wish to develop a *Personal Interpreter*, where in, i
will have to do Speech Recognition and Text-to-Speech on the mobile
device. With 0.9 SDK released, it shows the speech libraries but these
are not enabled.
I seriously request the Google`s Android Team to confirm, when will
the functionality be enabled as, if not the case in some near future,
my FYP will be dumped !!

I am desperately waiting for Google`s reply.


3. Can Android use as base core in mobile handset development?

4. How to get focus in list footer via key pad?

5. Need Android Developer for "e-reader" type project

6. Does Android support the linux 2.6.13 kernel?

7. ANdroid coding guidelines