Hi in my Android project I need to access some C++ code so I created shared library project on
Linux and generated .so file .
Now when I put this .so file inside libs/armeabi folder in my Android project and I load that .so file via code as
System.loadLibrary("name of so file without prefix lib and extention .so");
I am getting
12-30 17:01:12.628: E/AndroidRuntime(6472): java.lang.UnsatisfiedLinkError: Cannot load library: get_lib_extents[758]: 104 - /data/data/com.example.demo/lib/libextractimage.so is not a valid ELF object
Now I dont know why I am getting this issue and where is the problem
Please help me.
Related
I want to use .so lib file of another project into my own project.
There i am facing some problems i have put the .so file in JNILibs folder.
but the native methods in the .so file did not successfully loaded and give error that the Can not find the corresponding JNI Function.
so how i can solve this problem i have checked different solutions like
Call shared library (.so) methods within Android Studios C files
How do I package .so files into my .aar archive?
but they did not solve my problem.
i have no .cpp file nor .h file.
I have only .so file so how i can solve this problem.
thanks in advance.
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.
I have one android myLibrary.jar file. But myLibrary.jar file will load the native 3 different so file. I have a.so, b.so and c.so.
When i using in my own application, it just simply put the jar file to the Android Dependencies and all 3 so files put in the libs/armeabi of the main application package.
When deploy and install on the device, these so file will be in the data/data/my-appname/lib/*.so.
Now i need to provide the sdk solution. The user side doesn't want the main application. They just want the myLibrary.jar. So i am considering about packing all 3 *.so files to the jar. I searched for the how to add to the so files to myLibrary.jar. But i still don't understand.
In this following post:
[Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
It mentioned about adding the so file to the jar and extract at runtime. But i still don't understand how to achieve that.
After trying that mentioned in the following post:
Creating a product SDK: How do I add a native lib (.so) and a jar with the SDK I am creating?
After my sample application reference the the compiled jar that included the .so file. After installing to the device, the libs/armeabi/xxx is not unpacked on the install. So i would like to know how to extract them dynamically and save them to data/data/my-appname/lib/ so that i can use with System.loadlibary(.so).
Thanks a lot.
I have built an .so library for my Android program. Now I want to see the assembly code in that .so file in Mac. I tried otool but it outputs
xxx.so: is not an object file
So is there any way to dissect .so file in Mac?
I am trying to decode OGG files in Android using an NDK project (I've tried a few). No matter which one I try, I always get an error similar to this when I build:
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load videokit: findLibrary returned null
I'm very new to the NDK (obviously) so I'm not sure what I'm doing wrong. All I want to do is to be able to set the playback rate of an OGG file.
The java part of the code links to a shared library object (.so file), which is obtained by compiling the C++/NDK parts of the code with ndk-build. In this case, your app is not able to find the right .so file to load. Here are a few things you could check for -
Very basic check - did you run "ndk-build" inside the jni folder? If you didn't, no .so file is generated - eclipse will still compile your project, but it won't work.
If your project root directory is PROJECT, check $(PROJECT)/jni/libs/armeabi or $(PROJECT)/jni/libs/armeabi-v7a - either or both of the locations should contain a .so file once you are done with the "ndk-build" command.
Check that somewhere in your java code, you are invoking "System.LoadLibrary" on this .so file.
I think it should be "System.LoadLibrary(videokit)", but I am not sure.