Issue
I have a project about stitching images and I use opencv 2.4.5 and java. All my codes are java codes and it is running perfect when it's a java project. I transfered my code to android, imported opencv-245.jar and opencv_java245.dll to my project then I configured build path. But when my code comes to System.loadLibrary(...):
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat image1= Highgui.imread( imgs.get(0).toString() , 1);
Mat image2= Highgui.imread( imgs.get(1).toString() , 1);
...
It gives an error and couldn't load opencv native library(opencv_java245.dll). I searched it on the internet and read many things but didn't find an answer. Most of them were about android ndk but I don't use it and my codes are not c++. I tried to use System.load(path) but it failed again. Please give me any advice. Thanks.
UPDATE: Stack trace:
06-23 18:23:37.884: E/AndroidRuntime(443): FATAL EXCEPTION: main
06-23 18:23:37.884: E/AndroidRuntime(443): java.lang.IllegalStateException: Could not execute method of the activity
06-23 18:23:37.884: E/AndroidRuntime(443): at android.view.View$1.onClick(View.java:2704)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.view.View.performClick(View.java:3100)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.view.View$PerformClick.run(View.java:11644)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.os.Handler.handleCallback(Handler.java:587)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.os.Handler.dispatchMessage(Handler.java:92)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.os.Looper.loop(Looper.java:126)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.app.ActivityThread.main(ActivityThread.java:3997)
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.reflect.Method.invoke(Method.java:491)
06-23 18:23:37.884: E/AndroidRuntime(443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-23 18:23:37.884: E/AndroidRuntime(443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-23 18:23:37.884: E/AndroidRuntime(443): at dalvik.system.NativeStart.main(Native Method)
06-23 18:23:37.884: E/AndroidRuntime(443): Caused by: java.lang.reflect.InvocationTargetException
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.reflect.Method.invoke(Method.java:491)
06-23 18:23:37.884: E/AndroidRuntime(443): at android.view.View$1.onClick(View.java:2699)
06-23 18:23:37.884: E/AndroidRuntime(443): ... 11 more
06-23 18:23:37.884: E/AndroidRuntime(443): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_java245: findLibrary returned null
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.Runtime.loadLibrary(Runtime.java:425)
06-23 18:23:37.884: E/AndroidRuntime(443): at java.lang.System.loadLibrary(System.java:554)
06-23 18:23:37.884: E/AndroidRuntime(443): at org.myproject.stitching_android.SDCardToGridView.onClickStitching(SDCardToGridView.java:90)
06-23 18:23:37.884: E/AndroidRuntime(443): ... 14 more
Solution
The basic problem is that you are trying to load a dll on an Android device. A DLL is a Microsoft Windows only library, it can't be loaded by an Android app.
java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1108]: Library '/data/data/org.myproject.stitching_android/lib/opencv_java245.dll' not found
Means that your app can't find the file, even if it finds the file it won't be able to load it because Android doesn't support DLLs
Answered By - BackSlash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.