按照网上教程编得程序,运行时android程序直接异常退出:
附源码,java和cpp
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView JNITest = (TextView)findViewById(R.id.jniTextView);
String str = getJNItest();
JNITest.setText(str);
}
static{
System.loadLibrary("JNITest");
}
public native String getJNItest();
------------------------------------------------------
#include <jni.h>
#include <string.h>
extern "C"
_jstring* Java_com_john_helloJNI_getJNItest(JNIEnv* env, jobject thiz){
return (env)->NewStringUTF("hello FROM jni by ndkTest!");
}
看看能不能解决 http://www.cnblogs.com/javawebsoa/archive/2013/07/30/3225942.html
P.S JNI 用起来太麻烦 试试看JNA?