How to use c lib(.so) from android?

天大地大妈咪最大 提交于 2019-12-19 11:52:14

问题


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.

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.

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 failed: "/data/app/com.abc.xyz-2/lib/arm/libV1.so" has bad ELF magic

Problem:

  1. How to call .so shared library from android.

  2. How to include .so files on my project.


回答1:


Read first my answer here to add *.so libraries:

https://stackoverflow.com/a/33164947/3626214

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
                       ...
                    }

...
}


来源:https://stackoverflow.com/questions/38145641/how-to-use-c-lib-so-from-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!