Search code examples
androidopencvandroid-studiojava-native-interface

Android native libs not found


I'm testing opencv for android with native support. I have a simple app that change the camera image with its canny representation.

The problem I'm facing is that it works fine in a Moto G 1st gen (Android 5.0) but it doesn't in a Samsung Galaxy Grand Neo (API level 17)

The error I get is:

FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1636): could not load library "libopencv_java3.so" needed by "libnative-lib.so"; caused by load_library(linker.cpp:746): library "libopencv_java3.so" not found

I double check that that file exists under jniLibs/<ABI> and also with What's my ABI app from store check that both are armeabi-v7a.

I'm out of ideas. Any clue?

EDiT: Added more information

I forgot to mention that I'm using OpenCV for Android v3.1 and if you need the code you could find it here: https://github.com/leadrien/opencv_native_androidstudio


Solution

  • I've found the solution in this stackOverflow answer.

    Basically, what it says is to call System.loadLibrary after BaseLoaderCallback returns LoaderCallbackInterface.SUCCESS.

    Also while researching for this I came across with ReLinker v1.2 that states to be a robust method for loading native libraries. I'm also thinking in giving it a try. Here you can find its GitHub repo