I am trying to add an external library, Scandit. I keep getting this error:
java.lang.UnsatisfiedLinkError: Couldn't load scanditsdk-android-3.3.1 from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.clover.barcode2-1.apk,libraryPath=/data/app-lib/com.clover.barcode2-1]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java:365) .....
I assume it is because I am not properly including the .so file that comes with the library, but I can't figure out how to do it.
I am using Android Studio and I added the library by going to module settings -> libraries and added the directory with the jar and the directory with the so file.
Actually inside your JNI folder, android NDK which convert your native code like c or c++ into binary compiled code that is called "filename.so". You cannot read the binary code . so it wil create lib folder inside your libs/armeabi/ filename.so file. Show activity on this post.
These files are normally stored in /lib/ or /usr/lib/. On an Android device, SO files are stored within the APK under /lib//.
The SO file stands for Shared Library. You compile all C++ code into the.SO file when you write it in C or C++. The SO file is a shared object library that may be dynamically loaded during Android runtime. Library files are larger, often ranging from 2MB to 10MB in size.
You can add pre built *.so files in Android Studio using gradle 0.7.2+. First create the jniLibs at this location /app/src/main/ location and copy the all the folder with *.so files (armeabi, armeabi-v7a, mips, x86) in the jniLibs.
To use native-library (so files) You need to add some codes in the "build.gradle" file.
This code is for cleaing "armeabi" directory and copying 'so' files into "armeabi" while 'clean project'.
task copyJniLibs(type: Copy) { from 'libs/armeabi' into 'src/main/jniLibs/armeabi' } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(copyJniLibs) } clean.dependsOn 'cleanCopyJniLibs'
I've been referred from the below. https://gist.github.com/pocmo/6461138
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With