当前位置: 首页 > 面试题库 >

找不到本机方法

云凌
2023-03-14
问题内容

我有一个带有本机函数的小型JNI文件,该函数将char数组转换为字节数组(因此我可以将其发送到我的C ++客户端)。

定义如下:

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

软件包名称(加载库的位置是:

package com.example.communicationmoduleTCPIP

并且该类中的本机deffiniton如下:

// 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)是可运行的类吗?我不在类中运行,并且具有以下定义(当我注释本机函数时,服务器运行正常)

public class communicationmoduleTCPIP extends communicationmodule implements Runnable

我在网上环顾四周,阅读了一些我认为定义正确的文章后,有人可以告诉我我做错了什么吗?欢迎任何建议。


问题答案:

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



 类似资料:
  • 问题内容: 有一块代码可以在android 4.1.2上正常工作,但在4.0.3上却不能正常工作,崩溃日志为4.0.3 我收到UnsatisfiedLinkError异常 请指导我谢谢 这是我的课 这是我从中编译并创建二进制“ libsqliteX.so”文件的源cpp文件http://www.sqlite.org/android/tree?ci=trunk&re=jni|src/org/sqli

  • 我维护了无数个tomcat实例,但现在我遇到了一个以前从未遇到过的问题。 我得到了一条众所周知的日志消息,其中tomcat抱怨它在D:\Programme\Apache Software Foundation\tomcat 7.0\bin:中找不到本机库: web上充满了愚蠢的试错方法,而tomcat文档没有明确描述在什么情况下不将本机库放在bin-folder中。 其他信息: Apache To

  • 我已经翻阅了这里所有关于这个主题的其他帖子,但没有一个对我有帮助。 我使用的是一个第三方SDK(oovoo),它包含一个.jar文件和.so文件(armeabi-v7a) null 谢谢! android studio版本0.8.6 gradle版本1.12 Ooovoo版本1.2.4

  • 今天我发现了一些项目,演示了android ndk编程。这是这个项目 我正在尝试启动DroidBlaster项目。我已经编译了所有本机库,没有错误。结果如下: 我只是做了一些小的改变: 1). 添加到<code>AndroidManifest中的<code>应用程序选项<code>android:hasCode=“true” 2).我从本地activity扩展并加载activity的< code>

  • 我已经用本机库包装器创建了自己的jar。结果jar的结构为: 我按如下方式加载本机库: 现在我想在其他项目中添加这个库并使用它。但是当我创建MyLibClass的实例时,我收到一个错误: 我应该如何修复这个问题?

  • > 其中:构建文件'c:\users\wot\fdrrnc\node_modules\react-native-fbsdk\android\Build.gradle'行:30 错误:评估项目':react-native-fbsdk'时出现问题。找不到org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler