Hello, I first run samples found in androind ndk and I create my own
in C. I successfully print a hello world with c function.

but now I want to call c++ function. Then I change file extensions
to .cpp and remake with ndk-build. Ok that seems to work fine. I
refresh my eclispe project. Ok eclispe seems to find my hello world
function in new .so lib made in c++.

Then I launched debug and application failed because it does not find c
++ function. My function is the same but I modify jni function in it
to match c++ jni.

My TestSTL.java

package com.project.teststl;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class TestSTL extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        TextView  tv = new TextView(this);
        tv.setText( stringFromJNI() );
        setContentView(tv);
    }

    native public static String stringFromJNI();

    static {
                //System.loadLibrary("stlport_shared");
            System.loadLibrary("teststl");
        }

}

*************************************
my test.cpp file

#include <string.h>
#include <jni.h>

#include <stdlib.h>
#include <stdio.h>

/* Call to initialize the graphics state */
JNIEXPORT jstring JNICALL
Java_com_project_teststl_TestSTL_stringFromJNI(  JNIEnv* env, jobject
obj  )
{
        jstring s = (env)->NewStringUTF( "Hello from JNI !");

        return s;

}



I repeat, in C all is ok (I just modify NewStringUTF for C or C++
because are not the same definition).

Please help me.

-- 
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

Reply via email to