Search code examples
androidjavacv

UnsatisfiedLinkError for libopencv_core.so while .apk holds this library


I want to use JavaCv with my App on Android. Therefore I followed the advice here: https://github.com/bytedeco/javacv on how to install Android 2.2 or newer. As a result the following libraries can be found under \libs\armeabi: libjniopencv_core.so libopencv_core.so

All classes of both libraries are also present in the classes.dex file of my .apk. And still i get the following exception:

java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libopencv_core.so" needed by "libjniopencv_core.so"; caused by load_library(linker.cpp:745): library "libopencv_core.so" not found

I tried loading libopencv_core.so via

System.loadLibrary("libopencv_core")

and

System.loadLibrary("opencv_core")

with the same outcome..

Any hint on how to solve this issue would be appreciated.

Edit1:

I had a look to see which .so files could actually be found under /data/app-lib/ccc.android.myappname...

Despite libopencv_core.so and other files can be found under lib/armeabi/ in my .apk only some of them are available for my activity under /data/app-lib/ccc.android.myappname. The others are just ignored for some unknown reason.

Can somebody help, i have no idea what is going on.

Thank you.


Solution

  • Here the solution i found:

    I discussed this matter on the JavaCv board on Github:

    https://github.com/bytedeco/javacv/issues/28

    The Issue might be history with the next release, but for the meantime do as follows:

    Before using JavaCv for the first time run:

    static {
            System.loadLibrary("tbb");
            System.loadLibrary("opencv_core");
            System.loadLibrary("jniopencv_core");
    }
    

    On some devices (or occasion) the intended load order get mixed up...