package com.example.testndk;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv=new TextView(this);
tv.setText(stringFromJNI());
setContentView(tv);
}
public native String stringFromJNI();
static {
System.loadLibrary("hello-jni");
}
}
C/C++ code
#include <string.h>
#include <jni.h>
jstring
Java_com_example_testndk_TestNDK_stringFromJNI( JNIEnv* env,jobject thiz )
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
请问大家我的代码错在哪了 运行的时候报异常crash
java.lang.UnsatisfiedLinkError: stringFromJNI
package是com.example.testndk;
你的jni方法名应该是Java_com_example_testndk_MainActivity_stringFromJNI吧?