After updating from r6 to r7, the Android NDK could not find JNI_GetCreatedJavaVMs
I have updated my NDK version from r6 to r7. After that, I got this error while compiling one of my native files :
error: ‘JNI_GetCreatedJavaVMs’ was not declared in this scope
I’m building my project for API level 8 (Android 2.2). I checked
GetCreatedJavaVMs are declared, the file
jni.h is actually
a symbolic link to
Then I checked
It’s actually a file, not a symbolic link.
I’m building my project using Eclipse and the only thing I specify in my preferences is the path to
EDIT: Okay, it’s clear why I can’t find GetCreatedJavaVMs:
/* * VM initialization functions. * * Note these are the only symbols exported for JNI by the VM. */ #if 0 /* In practice, these are not exported by the NDK so don't declare them */ jint JNI_GetDefaultJavaVMInitArgs(void*); jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); #endif
But how do I get the VM in this case?
I found a solution.
You only need to implement the JNI_OnLoad (JavaVM* vm, void* reserved) function. The JVM is a parameter.
This might be a better way to get the JVM.