1 problem
ndk-build
error: 'get_string' undeclared here (not in a function)
2 resolve
jstring get_strstring(JNIEnv* env, jobject thiz)
{return (*env)->NewStringUTF(env, "I am chenyu, 动态注册JNI");
}jint add_int(JNIEnv* env, jobject jobj, jint num1, jint num2){return num1 + num2;
}/**
* 方法对应表
*/
static JNINativeMethod gMethods[] = {{"getStr", "()Ljava/lang/String;", (void*)get_str},{"addInt", "(II)I", (void*)add_int},
};
change to
jstring get_strstr(JNIEnv* env, jobject thiz)
{