未发现本机方法 [英] Native method not found

查看:139
本文介绍了未发现本机方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小JNI文件与本机的功能,一个字符数组转换为字节数组(这样我就可以把它送到我的C ++客户端)。

I have a small JNI file with a native function that converts a char array to a byte array (So i can send it to my C++ client).

的定义如下:

JNIEXPORT jbyteArray JNICALL Java_com_example_comtesttcp_communicationmoduleTCPIP_ConvertString(
        JNIEnv * env, jobject,
        jcharArray Buffer)

包名(其中库被加载是:

The package name (where the library is loaded is:

package com.example.communicationmoduleTCPIP

和在类中的本地deffiniton是为followd:

And the native deffiniton in the class is as followd:

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


  public native byte[] ConvertString(char[] Buffer);

但ConvertString函数被调用然后当我得到如下因素的错误:

But when the ConvertString function is called then i get the folowing error:

01-13 21:07:21.890:W / dalvikvm(22611):没有找到实现原生LCOM /例子/ communicationmoduleTCPIP / communicationmoduleTCPIP; .ConvertString:([C)[B 01-13 21:07:21.890:W / dalvikvm(22611):主题ID = 11:线程退出与未捕获的异常(组= 0x412b52a0) 01-13 21:07:21.900:E / AndroidRuntime(22611):致命异常:螺纹821 01-13 21:07:21.900:E / AndroidRuntime(22611):java.lang.UnsatisfiedLinkError中:本机方法未找到:com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.ConvertString:([C)[B 01-13 21:07:21.900:E / AndroidRuntime(22611):在com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.ConvertString(本机方法) 01-13 21:07:21.900:E / AndroidRuntime(22611):在com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.SendBuffer(communicationmoduleTCPIP.java:164) 01-13 21:07:21.900:E / AndroidRuntime(22611):在com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.RunServer(communicationmoduleTCPIP.java:107) 01-13 21:07:21.900:E / AndroidRuntime(22611):在com.example.communicationmoduleTCPIP.communicationmoduleTCPIP.run(communicationmoduleTCPIP.java:368) 01-13 21:07:21.900:E / AndroidRuntime(22611):在java.lang.Thread.run(Thread.java:856)

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)是可运行的类? I't运行中的一类,并具有以下定义(服务器时,我评论的原生功能运行正常)

Could the problem be that the class (communicationmoduleTCPIP) is a runnable class? I't runs in a class and has the following definition (the server runs fine when i comment the native function)

public class communicationmoduleTCPIP extends communicationmodule implements Runnable

我环顾四周在网上和阅读一些后,我认为定义权后,可以有一个人告诉我,我做错了吗?任何建议,欢迎。

I have looked around on the net and after reading some post i think definition right, can some one tell me what i'm doing wrong? Any suggestions are welcome.

推荐答案

本机方法名称应该与类全名: Java_com_example_communicationmoduleTCPIP_communicationmoduleTCPIP_ConvertString

the native method name should match the class full name: Java_com_example_communicationmoduleTCPIP_communicationmoduleTCPIP_ConvertString

这篇关于未发现本机方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆