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
Related
I have cross-compiled a gstreamer plugin for android. The .so file is installed in the same place as the other gstreamer plugins. I then build an android app having added the cross-compiled plugin name to my Android.mk file (the plugin name is passed to a seperate gstreamer-1.0.mk file to create the libgstandroid.so which is installed alongside the app on the phone).
I'm not yet using the plugin in my application source code, I am just attempting to build/include it in my app as a first step. When the app loads it has a FATAL EXCEPTION:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libgstplugin.so" not found
I'm not sure how to debug; it seems the plugin isn't being linked correctly into the libgstandroid.so?
I was able to solve this problem by building a static plugin library (and deleting the existing shared library as the gstreamer make process seems to choose the .so by default)
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
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 have compiled a JNI library for Android with the NDK that statically links against a libcrypto.a that I have compiled using this project, https://github.com/fries/android-external-openssl which dynamically links against libdl.so.
Even though the NDKs platforms/android-x/arch-arm/usr/lib directory has a libdl.so for every version of android when I try to load my library on Android 2.1 I get the following error:
Trying to load lib /data/data/package.name/lib/libmylibrary.so 0x44e83a28
Unable to dlopen(/data/data/package.name/lib/libmylibrary.so): Cannot load library: reloc_library[1244]: 30 cannot locate 'dladdr'...
and then proceeds to crash with an UnsatisfiedLinkError, but on 2.2+ my native library links and works perfectly
any thoughts on what is happening to me or how to fix it?
So while looking into this problem I have discovered that while libdl exists in all versions of android dladdr() was added to the C library in 2.2
the relevant lines of the NDK changes.html are as follows:
- C Library changes:
For android-8 (a.k.a. Android 2.2):
- add DL_info and dladdr().
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.