如何将现有的.so库添加到Android Studio项目? [英] How do you add an existing .so library to an Android Studio project?

查看:414
本文介绍了如何将现有的.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".

这篇关于如何将现有的.so库添加到Android Studio项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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