JNI | Exception on return from native code | IncompatibleClassChangeError: invoking method from interface not implemented by class
Weird one this,
Both my Java and C code seem to be working fine. However, when everything is done in the C code and the program would continue through the rest of the Java implementation the below Exception is thrown.
If forced to I'll simply wrap the call to native code in a try/catch but It worries me that an exception is being thrown for a reason unknown to me? Has anyone seen this before?
JavaCInterface.java (Extends Thread)
:
static {
Log.v(JavaCInterface.class.toString(), "Loading native libraries");
System.loadLibrary("JavaCInterface");
}
public native void cFunction();
@Override
public void run() {
super.run();
cFunction(); // Exception thrown when control is returned here
return;
}
JavaCInterface.cpp
:
JNIEXPORT void JNICALL Java_com_test_jni_JavaCInterface_cFunction(JNIEnv * env, jobject thiz)
{
... // Stuff happens here
logVerbose("Leaving Native Code"); // This gets logged fine and is the last line of the native method
}
Weird no? Any 开发者_高级运维thoughts?
ERROR/AndroidRuntime(2379): java.lang.IncompatibleClassChangeError: invoking method from interface not implemented by class
ERROR/AndroidRuntime(2379): at com.test.jni.JavaCInterface.cFunction(Native Method)
This error was actually caused by a "GetMethodID" failing unchecked previously in the code. Had to track this down like ViTo said by cutting to code up bit by bit
精彩评论