JNI |从本机代码返回的异常| IncompatibleClassChangeError:未通过类实现的接口调用方法

问题描述

|| 这很奇怪 我的Java和C代码似乎都可以正常工作。但是,当所有事情都在C代码中完成并且该程序将继续进行其余的Java实现时,将引发以下Exception。 如果被迫,我会简单地将对本机代码调用包装在try / catch中,但是让我担心的是,由于我未知的原因引发了异常?有没有人见过这个?
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
} 奇怪吗?有什么想法吗?
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)
    

解决方法

        此错误实际上是由\“ GetMethodID \”导致的,该错误先前未在代码中未经检查。不得不像ViTo所说的那样通过逐点编码来追踪     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...