I am developing an IPcamera control app using the libffmpeg.so and libobject_jni.so libraries provided by the IPcamera company. However I get this JNI ERROR (app bug): accessed stale local reference error while using the jni.
Here is my logcat output:
07-20 18:06:05.326 1576 1576 D dalvikvm: Trying to load lib /data/data/object.ipcam.client/lib/libffmpeg.so 0x4156ba68
07-20 18:06:05.357 1576 1576 D dalvikvm: Added shared lib /data/data/object.ipcam.client/lib/libffmpeg.so 0x4156ba68
07-20 18:06:05.357 1576 1576 D dalvikvm: No JNI_OnLoad found in /data/data/object.ipcam.client/lib/libffmpeg.so 0x4156ba68, skipping init
07-20 18:06:05.365 1576 1576 D dalvikvm: Trying to load lib /data/data/object.ipcam.client/lib/libobject_jni.so 0x4156ba68
07-20 18:06:05.372 1576 1576 D dalvikvm: Added shared lib /data/data/object.ipcam.client/lib/libobject_jni.so 0x4156ba68
07-20 18:06:05.372 1576 1576 I : void Java_object_ipcam_nativecaller_NativeCaller_StartPlay(JNIEnv*, _jobject*, jint, jint, _jstring*, jint, _jstring*, _jstring*, _jobject*, _jobject*):enter
07-20 18:06:05.372 1576 1576 I : ipaddr: 192.168.0.179, port: 80, user: admin, pwd: 123456
07-20 18:06:05.372 1576 1576 I : void Java_object_ipcam_nativecaller_NativeCaller_StartPlay(JNIEnv*, _jobject*, jint, jint, _jstring*, jint, _jstring*, _jstring*, _jobject*, _jobject*):leave
07-20 18:06:05.419 1576 1620 E dalvikvm: JNI ERROR (app bug): accessed stale local reference 0xc240002d (index 11 in a table of size 0)
07-20 18:06:05.419 1576 1620 E dalvikvm: VM aborting
07-20 18:06:05.419 1576 1620 E mono-rt :
07-20 18:06:05.419 1576 1620 E mono-rt : Attempting native Android stacktrace:
07-20 18:06:05.419 1576 1620 E mono-rt :
07-20 18:06:05.451 1576 1620 E mono-rt : at dvmAbort+113 [0x407cb01e]
07-20 18:06:05.451 1576 1620 E mono-rt : at IndirectRefTable::get(void*) const+336 [0x407add7c]
07-20 18:06:05.451 1576 1620 E mono-rt : at dvmDecodeIndirectRef(Thread*, _jobject*)+30 [0x407cf127]
07-20 18:06:05.451 1576 1620 E mono-rt : at ???+311871 [0x407d123f]
07-20 18:06:05.451 1576 1620 E mono-rt : at _JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+60 [0x518aeae8]
07-20 18:06:05.451 1576 1620 E mono-rt : at CCameraMediaSource::MessageNotify(int)+76 [0x518b0320]
07-20 18:06:05.451 1576 1620 E mono-rt : at CCameraMediaSource::RecvAVProcess()+884 [0x518b0ed8]
07-20 18:06:05.451 1576 1620 E mono-rt : at CCameraMediaSource::RecvAVThread(void*)+196 [0x518b11c8]
07-20 18:06:05.451 1576 1620 E mono-rt : at __thread_entry+48 [0x400d9c10]
07-20 18:06:05.451 1576 1620 E mono-rt : at pthread_create+172 [0x400d9368]
07-20 18:06:05.451 1576 1620 E mono-rt :
07-20 18:06:05.451 1576 1620 E mono-rt : =================================================================
07-20 18:06:05.451 1576 1620 E mono-rt : Got a SIGSEGV while executing native code. This usually indicates
07-20 18:06:05.451 1576 1620 E mono-rt : a fatal error in the mono runtime or one of the native libraries
07-20 18:06:05.451 1576 1620 E mono-rt : used by your application.
07-20 18:06:05.451 1576 1620 E mono-rt : =================================================================
07-20 18:06:05.451 1576 1620 E mono-rt :
07-20 18:06:05.451 1576 1620 F libc : Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 1620 (ct.ipcam.client)
My app's target API is 21 and it crash at this method:
void Java_object_ipcam_nativecaller_NativeCaller_StartPlay(JNIEnv*, _jobject*, jint, jint, _jstring*, jint, _jstring*, _jstring*, _jobject*, _jobject*)
However, this error is fixed when I set the target sdk to API 9. I read online that this is cause by the changes of the garbage collector since android 4.0. But My app use Android Support Library V7 Cardview which lowest support API is 15.
I don't want to give up using support Lib v7 in my app. So is there any way I can avoid this error in android 4.x? Or should I contact the camera company to let them provide a new version of the library? Since I don't know how to write jni. Thank you for reply.