c - Android ndk. Can't get reference to JVM -
a couple of days ago started having fun android ndk. trying compile 1 of sample programs book little problem arised.
so here need obtain reference javavm.
// global env ref (for callbacks) static javavm *g_vm; jniexport jint jnicall java_jni_natives_libmain (jnienv * env, jclass class, jobjectarray jargv) { // obtain global ref caller jclass (*env)->getjavavm(env, &g_vm); ...
eclipse says "method 'getjavavm()' not resolved
" every other line containing methods of (*env) object
.
includes directory has path: c:\programs\ide\adt-bundle-windows-x86_64-20130219\android-ndk-r8e\platforms\android-14\arch-arm\usr\include
don't think might include paths, can wrong.
are compiling .cpp file? <jni.h> has different jnienv implementations c , c++, , you're using c version. in c++ code this:
jniexport jint jnicall java_jni_natives_libmain (jnienv * env, jclass class, jobjectarray jargv) { // obtain global ref caller jclass env->getjavavm(&g_vm); ...
the normal way javavm reference in jni_onload:
jniexport jint jnicall jni_onload(javavm* vm, void* areserved) { // cache java vm g_vm = vm; ... }
Comments
Post a Comment