Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未找到本机方法 我有一个小的JNI文件,它有一个本地函数,它将字符数组转换为字节数组(这样我就可以把它发送给我的C++客户端)。_Java_Android_Eclipse_Multithreading_Java Native Interface - Fatal编程技术网

Java 未找到本机方法 我有一个小的JNI文件,它有一个本地函数,它将字符数组转换为字节数组(这样我就可以把它发送给我的C++客户端)。

Java 未找到本机方法 我有一个小的JNI文件,它有一个本地函数,它将字符数组转换为字节数组(这样我就可以把它发送给我的C++客户端)。,java,android,eclipse,multithreading,java-native-interface,Java,Android,Eclipse,Multithreading,Java Native Interface,定义如下: JNIEXPORT jbyteArray JNICALL Java_com_example_comtesttcp_communicationmoduleTCPIP_ConvertString( JNIEnv * env, jobject, jcharArray Buffer) 程序包名称(加载库的位置)为: package com.example.communicationmoduleTCPIP 类中的本机定义如下: // Load helper

定义如下:

JNIEXPORT jbyteArray JNICALL Java_com_example_comtesttcp_communicationmoduleTCPIP_ConvertString(
        JNIEnv * env, jobject,
        jcharArray Buffer)
程序包名称(加载库的位置)为:

package com.example.communicationmoduleTCPIP
类中的本机定义如下:

// Load helper functions library
static {
   System.loadLibrary("HelperFunctions");
}


  public native byte[] ConvertString(char[] Buffer);
但是当调用ConvertString函数时,我得到以下错误:

01-13 21:07:21.890: W/dalvikvm(22611): No implementation found for native Lcom/example/communicationmoduleTCPIP/communicationmoduleTCPIP;.ConvertString:([C)[B
01-13 21:07:21.890: W/dalvikvm(22611): threadid=11: thread exiting with uncaught exception (group=0x412b52a0)
01-13 21:07:21.900: E/AndroidRuntime(22611): FATAL EXCEPTION: Thread-821
01-13 21:07:21.900: E/AndroidRuntime(22611): java.lang.UnsatisfiedLinkError: Native method not found: com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.ConvertString:([C)[B
01-13 21:07:21.900: E/AndroidRuntime(22611):    at com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.ConvertString(Native Method)
01-13 21:07:21.900: E/AndroidRuntime(22611):    at com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.SendBuffer(communicationmoduleTCPIP.java:164)
01-13 21:07:21.900: E/AndroidRuntime(22611):    at com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.RunServer(communicationmoduleTCPIP.java:107)
01-13 21:07:21.900: E/AndroidRuntime(22611):    at com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.run(communicationmoduleTCPIP.java:368)
01-13 21:07:21.900: E/AndroidRuntime(22611):    at java.lang.Thread.run(Thread.java:856)
问题可能是类(communicationmoduleTCPIP)是一个可运行的类吗?我不是在类中运行的,并且具有以下定义(当我注释本机函数时,服务器运行正常)


我已经在网上浏览了一下,在阅读了一些我认为定义正确的帖子之后,有人能告诉我我做错了什么吗?欢迎任何建议。

本机方法名称应该与类全名匹配:
Java\u com\u示例\u通信moduletcpip\u通信moduletcpip\u ConvertString
谢谢你的回答,我我明天去检查一下。然后再打给你。(现在是晚上)
public class communicationmoduleTCPIP extends communicationmodule implements Runnable