如何从android使用c lib(.so)? [英] How to use c lib(.so) from android?
问题描述
目前我正在研究 Android NDK 并在 jni 中成功实现 C 代码,并在 android studio 1.5 上使用 jni 调用 C 代码.
Currently i am working on Android NDK and successfully implementing C code in jni and calling c code using jni on android studio 1.5.
但现在根据我的项目要求,我没有在我的 android 项目中使用 c 代码,所以我只使用 .so 共享库.
But now as per as my project requirement i am not using c code on my android project so i am using only .so shared library.
我得到了这个链接并使用了sqlcipher 但我仍然没有足够的知识来了解如何添加或调用 .so 共享库.
I got this link and used sqlcipher but still i don't have enough knowledge about how to add or call .so shared library.
参考上面的链接和示例,更新我的项目但出现错误
Refer above link and example, update my project but following getting error
java.lang.UnsatisfiedLinkError:dlopen 失败:/data/app/com.abc.xyz-2/lib/arm/libV1.so"有不好的 ELF 魔法
问题:
如何从android调用.so共享库.
How to call .so shared library from android.
如何在我的项目中包含 .so 文件.
How to include .so files on my project.
推荐答案
首先阅读我的答案以添加 *.so 库:
Read first my answer here to add *.so libraries:
https://stackoverflow.com/a/33164947/3626214
现在,在这里阅读如何解决 Android 6.X 设备上的 java.lang.UnsatisfiedLinkError: dlopen failed:
因为当您添加 *.so 库时,您将在此设备上收到错误消息:
And now, read here how to solve java.lang.UnsatisfiedLinkError: dlopen failed:
on Android 6.X devices because you'll get an error on this devices when you add *.so libraries:
build.gradle
android
{
//23 or higher
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig
{
...
//important code, write API 22
targetSdkVersion 22
...
}
...
}
这篇关于如何从android使用c lib(.so)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!