Itzik984
Itzik984

Reputation: 16774

Android JNI error: Call function with boolean argument causes a crash

I'm Trying to call this JAVA function:

public String getPreferredLanguage(boolean withRegion)

With JNI GetMethodID, But i always get a crash, i tried a lot of variations about the function signature in the JNI section, but none seemed to be helping.

The JNI code:

methodID getPreferredLanguageMethod = env->GetMethodID(languageServiceClass, "getPreferredLanguage", "(Ljava/lang/Boolean;Z)Ljava/lang/String;");
    if (!getPreferredLanguageMethod) {
        TTLOGD("LanguageService::getPreferredLanguage: ERROR getPreferredLanguageMethod is null\n");
    }

The crash message:

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;"

Any idea what i'm doing wrong?

Upvotes: 1

Views: 2277

Answers (1)

Itzik984
Itzik984

Reputation: 16774

Well after reading this document over and over, i found my problem, and this is how the JNI function should be:

jmethodID getPreferredLanguageMethod = env->GetMethodID(languageServiceClass, "getPreferredLanguage", "(Z)Ljava/lang/String;");

Upvotes: 3

Related Questions