Android Static Initialization opencv 3.0 Unable to load library "opencv_java3"

Using Android ADT am, I am trying to statically initialize openCV, so it is included in the application assembly, and users do not need to download OpenCV Manager from the Android game store.

Am uses openCV v3 ( http://opencv.org/downloads.html )

At the stage, it simply tries to add static initialization to one of the samples in OpenCV-android-sdk \ samples \ face-detection.

I followed the example ( http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html )

I looked at many examples, but have not yet found a solution for its work. I really hope that someone can help.

I thought maybe because libopencv_java3.so is not located in the libs/armeabi-v7a/ When I copy and paste it from OpenCV-android-sdk\sdk\native\libs\armeabi-v7a , it disappears. I believe this may be due to the way ndk is configured. Of course, the problem may be something completely different.

LogCat gives the following:

 11-26 16:36:33.647: D/OpenCV/StaticHelper(13993): Trying to load library opencv_java3 11-26 16:36:33.647: D/OpenCV/StaticHelper(13993): Cannot load library "opencv_java3" 11-26 16:36:33.647: W/System.err(13993): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java3 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.facedetect-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.facedetect-1, /vendor/lib, /system/lib, /vendor/lib]]]: findLibrary returned null 11-26 16:36:33.767: D/OpenCV/StaticHelper(13993): Trying to load library opencv_java3 11-26 16:36:33.767: D/OpenCV/StaticHelper(13993): Cannot load library "opencv_java3" 11-26 16:36:33.767: W/System.err(13993): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java3 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.facedetect-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.facedetect-1, /vendor/lib, /system/lib, /vendor/lib]]]: findLibrary returned null 
+7
java android opencv android-ndk
source share
3 answers

If someone encounters this problem and uses AndroidStudio. You can fix this by simply copying the OpenCV-android-sdk \ sdk \ native \ libs folder

in OpenCvProject / openCVLibrary310 / source / main and rename it to jniLibs. To make the final structure look like this: OpenCvProject / openCVLibrary310 / source / Main / jniLibs / enter image description here

If you have already launched your project from AndroidStudio, be sure to delete it first from the device. Otherwise, AndroidStudio may not redistribute it and may not copy lib files because of this.

It may also work if you copy the libraries to your actual project, and not to the openCVLibrary folder, but I did not.

+10
source share

Make sure that you have the option to install modules installed on "ON" before enabling Opencv.mk:

 OPENCV_INSTALL_MODULES:=on include ${OPENCV_ANDROID_SDK}/${ANDROID_SDK_JNI}/OpenCV.mk 

I already set my variables in the makefile

see: http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

+1
source share

I struggled with this problem for hours when I tried something just for fun and VOILÁ! I have a problem on System.loadLibrary("whateverYourLibraryWasCalled"); , so I add the loaded OpenCV just before:

 static { System.loadLibrary("opencv_java3"); System.loadLibrary("MyOpencvLibs"); } 

And everything works fine.

0
source share

All Articles