I’ve updated my NDK version from r6 to r7. After that I get this error when compiling one of my native files:
error: ‘JNI_GetCreatedJavaVMs’ was not declared in this scope
I am building my project for the API level 8 (Android 2.2). I’ve examined the
(MY_NDK_PATH_R6)/android-8/arch-arm/usr/include/jni.h
where the GetCreatedJavaVMs is declared and the file jni.h is actually a symlink to
(MY_NDK_PATH_R6)/platforms/android-3/arch-arm/usr/include/jni.h
Then I checked the
(MY_NDK_PATH_R7)/platforms/android-8/arch-arm/usr/include/jni.h
and it is actually a file, and not a symlink.
I’m building my project using Eclipse and the only thing I’ve specified in preferences is path to the ndk-build.
EDIT: OK, it’s clear now why GetCreatedJavaVMs could not be found:
/*
* 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 should I get the VM in this case?
I’ve found the solution.
You just need to implement the JNI_OnLoad(JavaVM* vm, void* reserved) function. JVM is an argument.
Probably this is better way of getting the JVM.