无法从JNI调用带有ArrayList对象的Java API

时间:2012-11-22 18:05:40

标签: java android java-native-interface

我正在尝试调用从JNI接受字符串的ArraList的Java API

/*My Java Method that needs to be called from JNI*/

public void postArrayListOfStringsToJavaFromJNI(ArrayList<String> list)
{
}

//I am trying to create the methodId like below in JNI to call my Java API postArrayListOfStringsToJavaFromJNI

jmethodID method_id = env->GetMethodID(dmrcallbacks, "postArrayListOfStringsToJavaFromJNI", "(Ljava/lang/Object;)V");

但我收到错误

11-22 23:22:45.130: E/AndroidRuntime(19189): java.lang.NoSuchMethodError: no method with name='postArrayListOfStringsToJavaFromJNI' signature='(Ljava/lang/Object;)V' in class Lcom/example/JavaSample;

GetMethodID调用是否有“(Ljava / lang / Object;)V”作为调用带有参数“ArrayList”的Java API的第一个参数

1 个答案:

答案 0 :(得分:2)

(Ljava/lang/Object;)V是采用void类型的单个参数的java.lang.Object方法的签名,您可能需要(Ljava/util/ArrayList;)V