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. Regular Emulator Runs... but not my Program (got past the scrolling red bar)

Hi roberle.

Can you please post your .java and .xml files? Without those, its
kind of difficult to figure out whats wrong.


[EMAIL PROTECTED] ha escrito:

2. Adding half screen view on a map


I want to show a view containing labels and buttons on lower half of
map when some locations on the map are clicked.

How do I add view on a mapview? or is there some other way to achieve
this? I would prefer to give layout thru XML.

This type of thing can also be seen in Commandro at



3. XML generate

4. Sharing Ideas

5. Regular Emulator Runs... but not my Program (got past the scrolling red bar)

6. can't run sample programs

7. To change "Home Application", possible??