First, you need absolutly the header (.h) containing the function declaration.
Secondly, you have to create a folder that contains your .so file, you can name it for example jniLibs
and put it in src/main/jniLibs
, then add the sourceSets
to you gradle file, into the android block :
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
NOTE : the jniLibs folder normally contains subfolders depending on the lib’s target ABI (arm64-v8a, armeabi-v7a, x86, x86_64), so you have to know it.
And finally you have to load the native library in the java side by adding :
/* Load jni .so on initialization */
static {
System.loadLibrary("my-native-lib-name");
}
And declare your function to use it like below :
public static native void myFunction(String arg, int another_arg);
5
solved Use .so (Shared object) file in Android studio