1

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.

Community
  • 1
  • 1
Amit
  • 51
  • 9

1 Answers1

2

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

...
}
Community
  • 1
  • 1
Aspicas
  • 4,498
  • 4
  • 30
  • 53
  • 1
    Thanks for very fast reply.. let me check but i have one more query how do i call C function?? – Amit Jul 01 '16 at 12:47
  • You can use a method `private native int/void/boolean nameMethod` to call native methods on yours activities, but that is another question, you can make another question to do that, another users may also need it in the future, and i'm sure people answer you faster too when you show your code problems. Try first to add libraries and don't get any compile error and later make another question. – Aspicas Jul 01 '16 at 12:52
  • @Amit : Hi Amit, I am working on the same issue, I have a .so file and now I need to import to my android Application and use the library. So how do we call the C functions?? – Abb Mar 15 '19 at 13:56
  • @Aspicas : Can you pls let me know how we can call methods in java using JNI from a already .SO. Please refer https://stackoverflow.com/questions/55263368/calling-so-functions-from-a-java-class-using-jni – Abb Mar 20 '19 at 14:41
  • @Amit : Please refer : https://stackoverflow.com/questions/55263368/calling-so-functions-from-a-java-class-using-jni – Abb Mar 20 '19 at 14:41