JNI CPP实现jni接口,采用方法名来识别本地方法的方式(相对于动态加载) 报错解决方法

No implementation found for native Lcom/dgut/android/MainActivity;.stringFromJNI ()Ljava/lang/String;

 

如果你确定方法名没有问题,那么就是本帖关键的地方所在了:

---------------com_centerm_util_MES_Nativie.h----------------

#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_centerm_util_MES_Nativie
 * Method:    testMacAddress
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_com_centerm_util_MES_1Nativie_testMacAddress
  (JNIEnv *, jclass, jstring);

#ifdef __cplusplus
}
#endif

---------------implement.cpp----------------

/*
 * Class:     com_centerm_util_MES_Nativie
 * Method:    testMacAddress
 * Signature: (Ljava/lang/String;)Z
 */

JNIEXPORT jboolean JNICALL Java_com_centerm_util_MES_1Nativie_testMacAddress
  (JNIEnv *, jclass, jstring){

 

}

 

--------------------------->

如果CPP文件里面的方法注释被删掉的话,so可以编译出来,但是运行时会报:

No implementation found for native Lcom/centerm/util/MES_Native;.testMacAddress (Ljava/lang/String)Z

posted @ 2018-01-18 19:32  刘轩舟  阅读(152)  评论(0编辑  收藏  举报