如何从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屋!