I'm trying to replicate this class called MediaMetadataRetriever in my own android project. You can see the class here:
https://android.googlesource.com/platform/frameworks/base/+/master/media/java/android/media/MediaMetadataRetriever.java
In line # 40 you can see: System.loadLibrary("media_jni");
How do I get that library? My logcat shows this:
Caused by: java.lang.UnsatisfiedLinkError: Library media_jni not found
This is a JNI class, which is created in C/C++ and included as a SO in your app. The class is loaded during runtime.
Look here https://android.googlesource.com/platform/frameworks/base/+/master/media/jni
Related
This is my error while trying to implement tesseract ocr
dlopen("/data/app-lib/app.my.myocr-12/liblept.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libjpgt.so" needed by "liblept.so"; caused by load_library(linker.cpp:745): library "libjpgt.so" not found
I am getting above error while trying to implement ocr using tesseract. I am using ndk 10 and have successfully built project. Can someone help me with my problem. Why am I getting this error
I had the same problem and found this:
github issue #150
Try adding this code to your app class:
static{
System.loadLibrary("jpgt");
System.loadLibrary("pngt");
System.loadLibrary("lept");
System.loadLibrary("tess");
}
After adding a library to project that contains native code (embedded as .so), my app build started to crash when running the dexguard<Flavor><BuildType> task.
The error says:
Caused by: java.io.IOException: Can't read [/home/user/project/app/build/intermediates/transforms/mergeJniLibs/flavor/buildType/folders/2000/1f/main(;;;;;;lib/*/*.so,lib/*/gdb*)] (Can't write resource [lib/x86/filecointainedonlibrary.so] (New string section exceeds the length of the original: 243 > 242))
That might happen when DexGuard obfuscates your native methods.
The latest version 7.1.29 should fix this issue, please give it a try.
Edit: The troubleshooting section of the DexGuard manual describes work-arounds when this happens. They basically keep names of native methods.
I am trying to create a Library project for andorid and I am using ORMLite.
Within my library project I have created ormlite_config.txt within the res/raw folder. However, when I make a jar of the library project, it gets sealed. So I get the following error.
java.alang.RuntimeException: Unable to start activity [activityName]: java.lang.IllegalStateException: Could not load object config file
Caused by: java.sql.SQLException: DatabaseTableConfig reading from stream cannot parse line: [random characters]
I have thought about using app specific config file stored on device and reading that. But with that is that I cannot get the application context when I run the DatabaseConfigUtility.
Has anyone ran into this problem before? Your help will be much appreciated!
in the class where you are extending OrmLiteSqliteOpenHelper you might be creating a constructor where you would call super class constructor just pass NULL in place of your "R.raw.ormlite_config", the ormlite_config file in my raw folder didn't contain any code , I had the EXACT SAME problem and this solved it for me. Hope this helps you.
I have already created .so file and put it in proper path.
However,when I try to run the android program the problem came by.
the problem is:
`5-16 15:34:16.704: E/AndroidRuntime(9968): Caused by: java.lang.UnsatisfiedLinkError:
Cannot load library: reloc_library[1311]: 1584 cannot locate '_Z13raptor_decodePKhtPKtPhjPK15RaptorParam_tag'...
raptor_decode is a function which included by the jni_function.`
what should i do to correct this problem? Thanks.
I think here is your problem:
1584 cannot locate '_Z13raptor_decodePKhtPKtPhjPK15RaptorParam_tag'
if raptor_decode is the method you want to call, read up here: http://java.sun.com/docs/books/jni/html/design.html (and read up 11.3)
I just finished compiling mupdf from mupdf.com on my mac. Took some time to figure it out but now I have a libmupdf.so in my libs/armeabi folder.
They provide an example of this class called MuPDFCore.java which is viewable here:
http://mupdf.com/repos/mupdf/android/src/com/artifex/mupdf/MuPDFCore.java
I used this class in my project and it says the following in LogCat:
Trying to load lib
/data/data/com.myapp.android/lib/libmupdf.so
0x4070e050
Added shared lib
/data/data/com.myapp.android/lib/libmupdf.so
0x4070e050
No JNI_OnLoad found in
/data/data/com.myapp.android/lib/libmupdf.so
0x4070e050, skipping init
No implementation found for native
Lcom/myapp/android/viewer/MuPDFCore;.openFile
(Ljava/lang/String;)I
DEBUG/AndroidRuntime(27523): Shutting
down VM
WARN/dalvikvm(27523): threadid=1:
thread exiting with uncaught exception
(group=0x400ee760)
ERROR/AndroidRuntime(27523): FATAL
EXCEPTION: main
ERROR/AndroidRuntime(27523):
java.lang.UnsatisfiedLinkError:
openFile
As far as I know the library is loading, before I figured out how to compile the library it kept crashing and saying the "mupdf" is a null link.
Their example pretty much says that openFile is a native function ... Just when I thought I figured this out another problem pops up. Ive been working on it all day. Any input would be great!
Is it a bad compile? I didn't get any errors in the terminal.
when you try to use it on your project with sample project's so files, it will throw "UnsatisfiedLinkError: Native method not found" exception. The cause is your app package name different from sample app package name("com.artifex.mupdf") because of jni binding system. You can solve this problem with below approaches:
1) long way: change mudef lib source code according to your package name, generate binaries(.so files) from it then use it in your project like #KuoCH said
2) short way: create "com.artifex.mupdf" package in your root source directory(beside project source folder, "src/main/java"), copy all classes from sample project to in it
At file mupdf.c L18-19:
#define JNI_FN(A) Java_com_artifex_mupdfdemo_ ## A
#define PACKAGENAME "com/artifex/mupdfdemo"
Change both to your package name.
I think you didn't change the your function names in mupdf.c to your corresponding java package name, that means, you should change the function Java_com_artifex_mupdf_MuPDFCore_openFile in your mupdf.c to Java_com_myapp_android_viewer_openFile.