I am trying to make a project to read pdf in android phone.
So, I created the normal Android Project and installed the android-ndk-r6-windows.
And I built the 'libmibookreader.so' and set the native functions in my java class.
But after compiling my project I have a serious Error.
Caused by: java.lang.UnsatisfiedLinkError: Library mibookreader not found
Why this error caused?
I really don't know. I referenced the address of "http://flytgr.thoth.kr/blog/697421".
I followed down as the reference document described.
This is because your library was not loaded by the kernel. Are you sure that you placed your library inside the libs/armeabi/ folder of your project?
Check the logcat when you deploy your application, you should see some messages there that your library was loaded.
If you don't you could also try to use System.loadLibrary(libPath); to manually load your library.
Related
I have a Visual C++ dynamic shared library (.so) project created using Xamarin.
I am also creating a Xamarin.Android app in the same solution and trying to add the dynamic shared library project as a reference, so that I can debug into the c++ code.
I am doing this by selecting 'Add Reference' on the Android app project and bringing up the 'Reference Manager'.
I see the dynamic library, check the box and hit OK.
The library gets added to the list of references with a yellow triangle indicating there is some problem. When I select it, I do see that the path property is empty.
I go ahead and build the project and I see in the Output window the following:
C:\Program Files
(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1550,2):
warning : Could not find file 'c:\users\documents\visual studio
2015\Projects\MySharedLibrary\x86\Debug\libMySharedLibrary.dll'.
No wonder the error, it is looking for the library with "dll" extension instead of the "so" extension.
What do I have to do to make the Android app reference the dynamic shared library(.so) for debugging?
-Thanks
Edit:
I get the same error even with the SanAngeles demo project and the sample project on the MSDN blog.
Edit2:
Direct reference to the .so lib works, it is the project reference to native library that throws this error.
I’m currently trying to create a .jar from a .dll, in order to use it on Android applications. I’m quite new with this technology, so I’ll tried to be as clear as possible.
I have 3 distinct parts:
A first .dll which is an API, in C++ and developed with Visual studio 2013.
A second .dll that makes the link between my API and Java code (using JNI, so this is my native library), also developed with Visual studio 2013.
And my Java code that loads my native library and that implements native functions from API. I use eclipse IDE for that stuff, because I read somewhere that was the easiest way to create a .jar.
This part works pretty well. I created a main test and I get all the information from the API in Java. But now, I would like to create a .jar file that I can use on Android and here comes the crows...
I tried many ways, from the simple .jar export, to the One-Jar method, but nothing worked. I always have a link error on my android platform (functions are recognized on the .jar, but their implementations are not).
So here is my question, how to create a kind of ‘static library’ in a .jar that I can use on Android?
I hope I was clear enough, don’t hesitate to ask me more details.
Thank you for your help!
EDIT:
I tried with an Android Library project and my problem is always coming from my loadLibrary() function:
public class MyWrapper {
static {
System.loadLibrary("MyWrapper");
}
public static native int getNegative(int p_number);
public static native int getPositive(int p_number);
}
Every things works fine on my library, but when I use it in android application, I always get this error:
01-27 11:31:29.565: E/AndroidRuntime(7089): FATAL EXCEPTION: main
01-27 11:31:29.565: E/AndroidRuntime(7089): Process: com.example.wrappertest, PID: 7089
01-27 11:31:29.565: E/AndroidRuntime(7089): java.lang.UnsatisfiedLinkError: Couldn't load MyWrapper from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.wrappertest-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.wrappertest-2, /vendor/lib, /system/lib]]]: findLibrary returned null
My library cound’t be created as static library, to keep the link on the .dll?
A .dll file is usually windows specific. If you're wanting to load native code on Android you'll have to look into using the Native Development Kit. The specifics of using the NDK is a bit beyond what can be explained here, but the Android Developer website provides a decent starting point at http://developer.android.com/tools/sdk/ndk/index.html
As for the jar itself, you may want to look into building an Android Library Project instead. This is essentially a means of packaging a jar with some assets (including native libraries) which can be used by an Android Application project.
Compile your librarie with ndk-build
Create an Android Library module
Create a Java class and JNI wrapper
Disable gradle for ndk-build and create Android.mk and Application.mk in the jni folder
Import the .so library and pre build it on the Android.mk
Invoke ndk-build manually and its done
I am using my own custom java library to read response from the server by hitting urls. I have written a standalone java program to check whether the library is working or not and I am getting the positive responses for all the urls. But when I am trying to use the same java library with my android code it is throwing me an exception.
Exception:
Could not find class 'org.apache.http.impl.conn.PoolingClientConnectionManager', referenced from method com.nq.client.comm.HttpClientHelper.<init>.
java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingClientConnectionManager
You probably want to export the library in your Java Build Path:
See Android - Unable to instantiate activity - Class not found exception after upgrading to ADT 22
EDIT
In your custom library project, make sure you are exporting in the Java Build path the Apache library (org.apache.http.impl.conn.PoolingClientConnectionManager). The error message is telling you that there is a reference to this library, but it cannot be found. This means that it's not being packaged with the library that is referencing it. So, go to your custom library project and make sure that the Apache library is getting exported. If it is, raise it up in the list in order of export.
Hello i'm using JNA to be able to use an external .dll(i don't have the header file but i have documentation thus the exposed function signatures).
I have managed to use my dll in a java project following the instructions here and now i'm trying to use the same thing on an android app.
I imporetd the jna jar in my libs and also added the jar in my buildpath and i'm getting an error
The library 'jna-3.5.1.jar' contains native libraries that will not run on the device.
The following libraries were found:
com/sun/jna/linux-amd64/libjnidispatch.so
com/sun/jna/darwin/libjnidispatch.jnilib
com/sun/jna/linux-i386/libjnidispatch.so
com/sun/jna/sunos-x86/libjnidispatch.so
com/sun/jna/sunos-amd64/libjnidispatch.so
com/sun/jna/sunos-sparc/libjnidispatch.so
com/sun/jna/sunos-sparcv9/libjnidispatch.so
Any ideas?
This deserves an answer...
Did you compile the lib you wanna use for android?
Why not write a JNI wrapper around those native libs, and invoke that from your android app?
Browse your jna.jar and delete the files displayed on your message :
com/sun/jna/linux-amd64/libjnidispatch.so
com/sun/jna/darwin/libjnidispatch.jnilib
com/sun/jna/linux-i386/libjnidispatch.so
com/sun/jna/sunos-x86/libjnidispatch.so
com/sun/jna/sunos-amd64/libjnidispatch.so
com/sun/jna/sunos-sparc/libjnidispatch.so
com/sun/jna/sunos-sparcv9/libjnidispatch.so
Then maybe you need to restart your IDE and that should work.
I want to make a pdf viewer program in android phone. So, I purchased the mupdf library.
I built the mupdf c++ classes and have 'libmibookreader.so' file.
And I also compiled the native function classes.
Then, I tried to run the application , but I have some errors.
Tag Message
AndroidRuntime java.lang.UnsatisfiedLinkError: open
i think you had not load library properly or may be you had not given the name properly in System.load("libname");
What is your android version?
on 2.1 and before, the lib libjnigraphics.so is missing and the mupdflib need it