Reputation: 2535
So I am trying to integrate CLE in Android and for this reason I have to add a few .so files. I am following a tutorial from here
Everything works fine till integrating the Star libraries, however when I run the program I get the following exception:
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.srplab.starcore/lib/libstar_java.so" not found
Now to include these .so files I have created a folder jniLibs and placed .so files for 3 architectures:
I ahve added the following lines of code to my build.gradle:
sourceSets
{
main
{
jniLibs.srcDirs = ['src/main/jnilibs']
}
}
However again when I run the below piece of code:
try {
//System.loadLibrary("mysharedlibrary");
System.load("/data/data/"+getPackageName()+"/libstar_java.so");
} catch (UnsatisfiedLinkError use) {
Log.e("JNI", "WARNING: Could not load libmysharedlibrary.so");
use.printStackTrace();
}
I am getting an exception, means the .so files did not load.
What is the proper way of doing this?
Upvotes: 0
Views: 842
Reputation: 1146
Your "armeabiv7a" folder must be renamed to "armeabi-v7a". Also there is typo in :
jniLibs.srcDirs = ['src/main/jnilibs']
Your folder is with big L:
jniLibs.srcDirs = ['src/main/jniLibs']
By the way, "src/main/jniLibs" is used by default for native libraries and you do not have to specify it in your gradle scripts.
There is not full block of code above, but do you load your library from static initializer? like:
static
{
System.loadLibrary("star_java");
}
And look at your apk to be sure that your lib were successfully gathered. You can see it at app/build/outputs/apk/
Upvotes: 2