Android crashing on JNI CallStaticObjectMethod
Hello there,
I'm trying to invoke a static method on Android and my app is crashing... the code is very simple, I ran out of ideas -- there isn't much I can think of that might be going on.
Here's the snippet:
char const *FileUtils::cachesDir() {
JavaVM *vm = JniHelper::getJavaVM();
JNIEnv *env;
int status = vm->GetEnv((void **)&env, JNI_VERSION_1_4);
if(status >= 0){
jclass cls = env->FindClass("android/content/ContextWrapper");
jmethodID method = env->GetMethodID(cls, "getFilesDir", "()Ljava/io/File;");
jobject result = env->CallStaticObjectMethod(cls, method, NULL); **// <-- ***** CRASHES WITH java.lang.NullPointerException at android.content.ContextWrapper.getFilesDir(ContextWrapper.java:193) *****
return "Found a result";
}
return "NULL";
}
Thougts?
Thanks and regards,
- Fabiano
Edited by: user10784680 on Jan 1, 2013 7:06 AM