How to add prebuilt .so library in android studio 0.8.6 - android

The Error I will get is
Couldn't load json from loader dalvik.system.PathClassLoader[DexPathList[dexElements=[zip file "/data/app/com.uei.tools.ndktest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.uei.tools.ndktest-1, /vendor/lib, /system/lib]]]: findLibrary returned null
I created a zip file of all .so files and i added into libs folder under app folder i added jar dependency from Module settings dependency.
All serch resulted in sample code of old versions of android studio but there is no sample for Android studio 0.8.6 beta

With Android Studio 0.8.x, you can directly add your prebuilt .so files under a jniLibs folder, inside folders corresponding to each ABIs. For example:
app/src/main/jniLibs/armeabi-v7a/libMyLib.so
app/src/main/jniLibs/x86/libMyLib.so
You can find up-to-date samples at the bottom of this page: http://tools.android.com/tech-docs/new-build-system#sites-attachments

Related

After deleting jar file from lib getting error from gradle while building project

I have added a jar file inside app/libs folder. then right click and added jar file as library.The project builds perfectly. After that I have deleted the jar file from libs folder.
Now its showing a Failed to create MD5 hash for file.
using android studio - 2.3.1
I have checked this solution but didn't find anything inside my gradle file.
If you can see the above picture in Android Studio this would be your project structure. Check the Dependency and see if the Jar is still available in the Project

Secugen sdk not working in xamarin

I am trying to use secugen sdk in which I have binded a jar with project. I have added required jar and .so files to project.I have added required .so files by making a lib folder and inside lib folder making sub folders armeabi and x86.
Inside this sub folders I have placed the .so files.At runtime I'm getting exception as follows:
Java.Lang.UnsatisfiedLinkError:
dalvik.system.PathClassLoader[DexPathList[[zip file
"/data/app/fingerprint.fingerprint-1/base.apk"],nativeLibraryDirectories=[/data/app/fingerprint.fingerprint-1/lib/arm,
/data/app/fingerprint.fingerprint-1/base.apk!/lib/armeabi-v7a,
/vendor/lib, /system/lib]]] couldn't find "libjnisgfplib.so"

Android NDK Unsatisfied link error of .so file of another AAR project

I have one Android AAR project which contains .so file in jnilibs folder. when i try to include this aar file in other android project(non-ndk) it works fine and system.loadlibrary("Mysample.so") returns successfully.
But when i try to include the same aar in android-ndk project, system.loadlibrary("Mysample.so") throws unsatisfiedlinking error.
I wonder why its just doesnot work in android ndk project?
Any help would be appreciated.

Unable to access Native .so files in Android Studio

I am trying to add armeabi .so files in my Android Studio project. Which will be accessed by .jar files of an SDK. Basically I am using Brothers Printers SDK and integrating them in my app. THe problem is, the .jar files are picked up in the Android Studio Project but when I try to access a method of the SDK, it gives me this error:
java.lang.UnsatisfiedLinkError: Couldn't load createdata from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.wingoku.printerapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.wingoku.printerapp-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.brother.ptouch.sdk.JNIWrapper.<clinit>(JNIWrapper.java:16)
at com.brother.ptouch.sdk.Printer.setPrinterInfo(Printer.java:887)
at com.wingoku.printerapp.print.printprocess.BasePrint.setPrinterInfo(BasePrint.java:73)
at com.wingoku.printerapp.print.printprocess.BasePrint$PrinterThread.run(BasePrint.java:433)
I have tried putting the armeabi folder inside the src/main/jniLibs but the .so files are not getting picked up and I keep getting the mentioned exception.
What can I do resolve it?
The method which helped me is:
make a directory on your desktop name it 'lib'
take your jnilibs folders with *.so files and paste it in lib.
now zip your lib folder
and then change its extention from .zip to .jar
that is lib.zip to lib.jar
now copy this into your libs folder of your project and update you gradle by adding this line in dependencies:
compile fileTree(include: 'lib.jar',dir:'libs')
this is the safest method to load any jnilibs. i applied it with opencv libs
if also problem persists add reference of NDK-root in your app.
hope this helps.

Why the manually added .so file in libs is automatically deleted by running the Android project?

I have an Android project A, with ndk and jni features.
It also links to another library project B.
In order to make things simpler, I remove the linked library project B,
and add the compiled .jar file and its .so files in /libs from B.
I put a line
System.loadLibrary("libfromB.so");
Now I clean and rebuild the project A. All is fine.
I find that every time I run the project, libfromB.so in /libs is deleted.
So it will complain:
02-21 17:47:26.493: E/AndroidRuntime(24086): java.lang.UnsatisfiedLinkError: Couldn't load fromB from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.android.askquestion.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.android.askquestion.app-1, /vendor/lib, /system/lib]]]: findLibrary returned null
However, I see some Android projects from open source, they have some .so files put in /libs, and they are not deleted automatically.
You should not put your .so files directly under the libs/ directory, but rather under an architecture appropriate subdirectory, for example
project/libs/armeabi/libfromB.so
It is possible that if your IDE believes your project has native code, it might be running an NDK build subsystem which is cleaning that directory.
System.loadLibrary() takes a short library name, not a filename. So if your library is called "libfromB.so" you should use
System.loadLibrary("fromB");

Categories

Resources