我试图调用此JAVA
函数:
public String getPreferredLanguage(boolean withRegion)
使用JNI
GetMethodID
,但我总是遇到崩溃,我在JNI
部分尝试了很多关于功能签名的变体,但似乎没有任何帮助。
JNI
代码:
methodID getPreferredLanguageMethod = env->GetMethodID(languageServiceClass, "getPreferredLanguage", "(Ljava/lang/Boolean;Z)Ljava/lang/String;");
if (!getPreferredLanguageMethod) {
TTLOGD("LanguageService::getPreferredLanguage: ERROR getPreferredLanguageMethod is null\n");
}
崩溃讯息:
JNI DETECTED ERROR IN APPLICATION: JNI CallObjectMethodV called with pending exception java.lang.NoSuchMethodError: no non-static method "Lcom/tabtale/mobile/acs/services/LanguageService;.getPreferredLanguage(Ljava/lang/Boolean;Z)Ljava/lang/String;"
知道我做错了吗?
答案 0 :(得分:3)
在一遍又一遍地阅读this文档之后,我发现了我的问题,这就是JNI
函数应该是这样的:
jmethodID getPreferredLanguageMethod = env->GetMethodID(languageServiceClass, "getPreferredLanguage", "(Z)Ljava/lang/String;");