I am using NDK with cocos2dx. In main.cpp, I have the following method.
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env,
jobject thiz, jint w, jint h)
Is it possible to assign jobject thiz to another object and use in cpp? Just like this:-
static jobject context = NULL;
void Manager::SetJobject(jobject object)
{
context = object;
}
.............
// in some other class
//if platform == ANDROID
connectToSomeThirdParty(context, key );
I tried this , but I got crash. Crash log is shown below:
10-01 11:38:13.228: E/dalvikvm(5828): JNI ERROR (app bug): attempt to use stale local reference 0x1e200001
10-01 11:38:13.228: E/dalvikvm(5828): VM aborting
10-01 11:38:13.228: A/libc(5828): Fatal signal 6 (SIGABRT) at 0x000016c4 (code=-6), thread 5857 (Thread-577)
Thanks in advance.