[英]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
),则必须确保:
Also check that System.loadLibrary()
ends successfully, without error logs in logcat. 还要检查System.loadLibrary()
成功结束,并且在logcat中没有错误日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.