如何将现有的.so库添加到Android Studio项目?

如何将现有的.so库添加到Android Studio项目?

问题描述:

有很多资料表明,您应该在src/main/中创建一个名为jniLibs/armeabi的目录,并将已编译的.so文件添加到该位置.然后使用System.loadLibrary("nameOflib")加载您的库.

There are several sources out there that say you should create a directory in src/main/ called jniLibs/armeabi and add your compiled .so file to this location. Then load your library using System.loadLibrary("nameOflib").

我的问题是,当我定义函数时

My issue is that when I define my function

public native long create();

create()给出错误:

create() gives the error:

无法解析相应的JNI函数Java_com_brendan_myApplication_MainActivity_create. 报告Java中的本机方法声明,而在项目中找不到相应的JNI函数.

Cannot resolve corresponding JNI function Java_com_brendan_myApplication_MainActivity_create. Reports native method declarations in Java where no corresponding JNI function is found in the project.

有什么想法吗?

结果发现即使出现错误,我仍然可以调用jni方法 无法解析相应的JNI函数".

Turns out I can still call the jni methods even though there is an error saying "Cannot resolve corresponding JNI function".