I have an android project, that has native code. In this native part I use OpenCV. Everything compiles and works OK when I use OpenCV 2.3.1, but when I tried to switch to version 2.4.1, I faced problem:
It compiles without any errors, but when I start my app, it can't load my library because of UnsatisfiedLinkError.
Cannot load library: link_image[1936]: 37 could not load needed library 'libopencv_java.so' for 'mylibrary.so' (load_library[1091]: Library 'libopencv_java.so' not found)
I see that Open CV tries to load libopencv_java.so, but I do not need it and I don't use OpenCV in java code. This library's size >5M.
How to compile without adding this lib to project?
The libopencv_java.so in addition to JNI wrappers to C++ OpenCV interface contains all the OpenCV native code.
When you build your JNI library with OpenCV 2.4 for Android you can either link dynamically with libopencv_java.so (default option) and include it into your APK or link statically by adding this option explicitly:
include $(CLEAR_VARS)
OPENCV_LIB_TYPE:=STATIC
include <your path>/OpenCV.mk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With