I receive error message when run JNI android app A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 17729

I got an error when i run android app that I use JNI functions and c++ code in it. When it run, I got below message:

Fatal signal 11 (SIGSEGV) at 0xe480001d (code=1), thread 5465

And finally here is my codes:

JNIEXPORT jstring JNICALL Java_ir_bassir_ndktest4_MainActivity_getName
(JNIEnv *env, jobject obj){

  jclass cls = (*env)->GetObjectClass(env, obj);
  jmethodID mid = (*env)->GetStaticMethodID(env, cls, "testJava", "([Ljava/lang/String)[Ljava/lang/String");

  jstring plainText = (*env)->NewStringUTF(env, "Hello from JNI ! Compiled with ABI  2222 ");
  jstring result = (*env)->CallStaticObjectMethod(env, cls, mid, plainText);

  return (*env)->NewStringUTF(env, plainText);
}

And on the Java side:

public class MainActivity extends ActionBarActivity {

    public native String getName();

    public static String testJava(String txt){
        Log.d("BP","call back to java method");
        String result = txt + "its added in JAVA";
        return result;
    }

    static{
        System.loadLibrary("HelloJNI");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String name = getName();

        Log.d("BP",name);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


Source: c++

Leave a Reply