JNI文件中命名类与JAVA文件中匹配
jni.c中注册中
int register_android_boa(JNIEnv *env)
{
jclass
clazz;
static const char* const kClassName =
"com/lxl/ledClass"; //命名的类
/* look up the class */
clazz =
(*env)->FindClass(env,kClassName);
// clazz =
env->FindClass(env,kClassBoa);
// clazz =
(*env)->FindClass(kClassName);
if (clazz == NULL)
{
LOGE("Can‘t find class %s\n",
kClassName);
return
-1;
}
/* register all the methods */
if
((*env)->RegisterNatives(env,clazz, gMethods, sizeof(gMethods) /
sizeof(gMethods[0])) != JNI_OK)
//if
(env->RegisterNatives(env,clazz, gMethods, sizeof(gMethods) /
sizeof(gMethods[0])) != JNI_OK)
{
LOGE("Failed registering methods
for %s\n", kClassName);
return
-1;
}
/* fill out the rest of the ID cache
*/
return 0;
}
则在JAVA工程中使用这个库时必须有com.lxl.ledClass.java这个文件