Android loadLibrary path not found - java

I'm using System.loadLibrary("xxxx"); to load the library but I'm getting the error message again.
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.xxxxxxxxxxxxxxxxx/base.apk"],nativeLibraryDirectories=[/data/app/com .xxxxxxxxxxxxxxxxx/lib/arm64, /system/lib64, /product/lib64]]] couldn't find "libchilkat.so"
Java code:
static {
System.loadLibrary("chilkat");
}
My Libs
================================================
UPDATE
When you just enter Android Studio, it will create a folder named libs at the path <Project>\app\libs
I moved the libs folder to the path <Project>\app\src\main\
and extra gradle file
android {
....
sourceSets {
main.jniLibs.srcDirs = ['libs']
}
}
it worked fine for me

Related

Trouble referencing a .so file in android studio

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?
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/

Couldn't find "liballjoyn_java.so"

I'm working on an android chat room with alljoyn service. In the libs folder I have created the folder armeabi and added the liballjoyn_java.so file there.
I have added the dependencies necessary but I keep getting this error:
Couldn't find "liballjoyn_java.so"
when I try to load the library:
static {
Log.i(TAG, "System.loadLibrary(\"alljoyn_java\")");
System.loadLibrary("alljoyn_java");
}
I don't know where the problem is.
I think your java-library-path is unable to locate the alljoyn_java folder.
try using
System.load(absolute path to the alljoyn_java folder)
alljoyn_java folder must be in the
core->alljoyn folder

Android java.lang.UnsatisfiedLinkError with native library

I tried to use some native library and received some Exception with underlying exception UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: Couldn't load viblast: findLibrary returned null
I am using Android Studio + gradle.
It looks like android can't find the native library in APK file.
My projects tree:
I tried to put them in "jniLibs" directory, but it doesn't helped me. I think I forget to write something in gradle files, but I can't figure out what.
Create Folder "jniLibs" inside your "src/main/" and put all your .so files inside "src/main/jniLibs" folder. In your screenshot I can't find "jniLibs".
Please follow below steps :
Add the path of your NDK in the local.properties file, located to
the root directory of your project.
add these lines to your app build.grade files :
sourceSets {
main {
jni.srcDirs = ["libs"]
}
}
Remove old .so files from your app.
Go to the directory src/jni directory of your app project and run the command :
PATH_TO_YOUR_NDK/ndk-build
The project is compiling and your get your lib (.so) under the directory libs of your modules.
5.the libraries into your main app should be like below structure.
Please for reference visit this link..!!
Thanks..!!

How to load jingle_peerconnection_so.so file to an android project in eclipse?

I get the following error while running the project. I don't know how to add jingle_peerconnection_so.so file to an android project in eclipse?
java.lang.UnsatisfiedLinkError: Couldn't load jingle_peerconnection_so from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.nandha.quickblox.videocall-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.nandha.quickblox.videocall-1, /vendor/lib, /system/lib]]]: findLibrary returned null
use System.load("location of .so file"); or
System.loadLibrary("location of .so file");
It's a JNI file thats missing.
Add the file libjingle_peerconnection_so.so to your jniLib folder inside src/main
This file should be in the output directory of the webrtc folder

Unable to load .so file

I have an application which uses one native library "libSample.so" which is depend upon another .so file.I am trying to load that library using following code
File File1 = new File("libSample.so");
static
{
try {
System.load(File1.getAbsolutePath());
} catch (UnsatisfiedLinkError e) {
System.out.println("Link Error");
}
}
Before loading library I have tried setting up LD_LIBRARY_PATH where the library is located using command line.
export LD_LIBRARY_PATH=/home/usb:${LD_LIBRARY_PATH}
But still the library not get load.
What should I do now?
Please help.
static {
System.loadLibrary("libSample.so");
}
I assumed that you have your jars in /libs directory and .so file in /libs/armeabi directory so the system finds them. You do not have to add .so files in your eclipse build path.

Categories

Resources