How to generate .so file and the corresponding Java interface in Android Studio

Viewed 4761

I want to generate a SO file and its corresponding Java interface for using it into another project.

What I have done so far:

I have created a project in Android Studio 2.3.3 (the latest version of 2017-08-09) with 'Include C++ support' and wrote some C/C++ code and compile it and when I run the program it was successfully called and returned a "Hello from JNI" string.

So after that, I looked the output for the generated .so file, but there I did not find this file. After that, I found the generated APK file in the output folder and when I extracted it, inside I found these folders which all contain .so file:

  • arm64-v8a
  • armeabi
  • armeabi-v7a
  • mips
  • mips64
  • x86
  • x86_64

Now the question is, how can I use these .so files into another project, because of this I searched a lot on the internet, but unfortunately, I did not find any solution, the solution that they mentioned all was to create a folder in the main folder of the project name it jniLibs and after modify the Gradle file and so ..., but no one was working.

Here I want to know that how can we add the .so file and the corresponding Java interface to use them in the project?

It is the error that now I get to the new project when trying to call the JNI function in the .so file.

enter image description here

2 Answers
Related