3

I struggle with a very annoying problem. I have an app which uses the OpenCV library for Android. The problem is that it throws me the following exception:

12-07 14:19:27.420: E/AndroidRuntime(19108): FATAL EXCEPTION: main
12-07 14:19:27.420: E/AndroidRuntime(19108): java.lang.UnsatisfiedLinkError: Couldn't load libopencv_java.so from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.elsys.coursework.smartcam-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.elsys.coursework.smartcam-2, /vendor/lib, /system/lib]]]: findLibrary returned null
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.Runtime.loadLibrary(Runtime.java:355)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.System.loadLibrary(System.java:525)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at org.elsys.coursework.smartcam.MainActivity.<clinit>(MainActivity.java:110)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.Class.newInstanceImpl(Native Method)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.Class.newInstance(Class.java:1130)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.ActivityThread.access$600(ActivityThread.java:149)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.os.Looper.loop(Looper.java:137)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at android.app.ActivityThread.main(ActivityThread.java:5214)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.reflect.Method.invokeNative(Native Method)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at java.lang.reflect.Method.invoke(Method.java:525)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
12-07 14:19:27.420: E/AndroidRuntime(19108):    at dalvik.system.NativeStart.main(Native Method)

I searched for solutions but nothing worked. I tried to add libopencv_java.so to the libs/armeabi-v7a folder manually but every time I add it, the eclipse deletes it automatically by itself.

Here are and the mk files:

Android.mk

    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)

    include  /home/crash-id/Development/SDK/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk

    LOCAL_MODULE := orbdetector
    LOCAL_SRC_FILES := ORBDetector.cpp
    LOCAL_LDLIBS +=  -llog -ldl


include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
dephinera
  • 3,703
  • 11
  • 41
  • 75
  • Possible dup http://stackoverflow.com/questions/10857301/unable-to-link-native-library-in-opencv-android-sample – Shmil The Cat Dec 07 '14 at 12:58
  • I tried what is said in the answer of the possible duplicated question. If you read my question you will see that I said I tried to copy libopencv_java.so to libs/armeabi-v7a folder and I said that eclipse deletes it. – dephinera Dec 07 '14 at 13:06

1 Answers1

-1

Do you have the 'opencv library 2.4.X.jar' file under your project properties -> Java Build Path -> Libraries tab -> under Android Dependencies ? Maybe try removing the library under Project Properties > Android > Library (if you have it marked), and then adding the jar file i mentioned before.

MichaelR
  • 83
  • 6