简体   繁体   English

Android-java.lang.UnsatisfiedLinkError:未找到本机方法

[英]Android - java.lang.UnsatisfiedLinkError: Native method not found

IDE: Android Studio IDE:Android Studio

I have the static library located under the "jniLibs" folder. 我在“ jniLibs”文件夹下有静态库。

在此处输入图片说明

I also loaded that library. 我还加载了该库。 Here is the code I used: 这是我使用的代码:

static 
{
    System.loadLibrary("elianjni");
}

The native methods were declared on a separate class(ElianNative) as: 本机方法在单独的类(ElianNative)上声明为:

public native int InitSmartConnection(String paramString, int paramInt1, int paramInt2);    

public native int StartSmartConnection(String paramString1, String paramString2, String paramString3, byte paramByte);

However when I called the method InitSmartConnection the app crashed and the error was: 但是,当我调用方法InitSmartConnection ,应用程序崩溃了,错误是:

java.lang.UnsatisfiedLinkError: Native method not found: com.monitor.camera.connect.ElianNative.InitSmartConnection:(Ljava/lang/String;II)I

at com.monitor.camera.connect.ElianNative.InitSmartConnection(Native Method) 

I don't know the possible cause of this because I just copied this library from another WORKING project and then did the same thing on declaring the methods and importing the necessary headers. 我不知道可能的原因,因为我只是从另一个WORKING项目复制了该库,然后在声明方法和导入必要的标头方面做了同样的事情。

What can be the possible cause of such problem? 可能导致这种问题的原因是什么? I searched on stack, some say that it's the absence of Java keyword before the method in the .c file. 我在堆栈上搜索,有人说这是.c文件中的方法之前缺少Java关键字的原因。 However I don't think that this can be the problem because like what I said, this is used in another project which is working fine. 但是我不认为这可能是问题所在,因为就像我说的那样,它被用在另一个运行良好的项目中。

If you have copied native library binary files ( .so ) from other project you must ensure that: 如果您已从其他项目复制了本机库二进制文件( .so ),则必须确保:

  • declarations of native methods in java are still the same, ie both method name and signature remain unchanged Java中本机方法的声明仍然相同,即方法名称和签名均保持不变
  • declarations of native methods are placed in the class with the same name and package as in donor project. 本地方法的声明以与捐助者项目中相同的名称和包放置在类中。

Also check that System.loadLibrary() ends successfully, without error logs in logcat. 还要检查System.loadLibrary()成功结束,并且在logcat中没有错误日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.UnsatisfiedLinkError:找不到本机方法: - java.lang.UnsatisfiedLinkError: Native method not found: java.lang.UnsatisfiedLinkError:找不到本机方法 - java.lang.UnsatisfiedLinkError: Native method not found java.lang.UnsatisfiedLinkError:在Android中找不到本机方法 - java.lang.UnsatisfiedLinkError: Native method not found in Android 奇怪的java.lang.UnsatisfiedLinkError:找不到本机方法: - Weird java.lang.UnsatisfiedLinkError: Native method not found: java.lang.UnsatisfiedLinkError:找不到本机方法:create - java.lang.UnsatisfiedLinkError: Native method not found: create java.lang.UnsatisfiedLinkError:找不到本机方法:jni()出错 - java.lang.UnsatisfiedLinkError: Native method not found: Error in jni() java.lang.UnsatisfiedLinkError:找不到本机方法:com.badlogic.gdx.backends.android.AndroidGL20.glGenTexture :() - java.lang.UnsatisfiedLinkError: Native method not found: com.badlogic.gdx.backends.android.AndroidGL20.glGenTexture:() linphone android登录错误java.lang.UnsatisfiedLinkError:找不到本机方法 - linphone android login error java.lang.UnsatisfiedLinkError: Native method not found java.lang.UnsatisfiedLinkError-本机方法问题 - java.lang.UnsatisfiedLinkError - Native method issue Android java.lang.UnsatisfiedLinkError与本机库 - Android java.lang.UnsatisfiedLinkError with native library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM