OpenCV on Android: Couldn't load opencv_java from loader - do I have to compile with NDK? Have I missed something? -
i feel i've missed obvious here. i'm trying opencv run on android. wanted use static initialization method, copied appropriate native library files opencv sdk app/libs/armeabi-v7a folder within android studio project. know google glass (what i'm developing for) uses architecture - , in case, have /lib/armeabi folder in case.
i searched here on stackoverflow, , of course answers.opencv.org down. answers found didn't solve problem. far understand it, i:
- install ndk android
- download , extract opencv sdk
- import android library , add module dependency
- copy library files /libs/armeabi-v7a (within android studio project)
use following code , library should load correctly:
if (!opencvloader.initdebug()) { log.e("opencv","unable load opencv"); } else { log.e("opencv","opencv has loaded!"); }
however, error:
12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ trying library list 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest e/opencv/statichelper﹕ opencv error: cannot load info library opencv 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ library list: "" 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ first attempt load libs 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ trying init opencv libs 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ trying load library opencv_java 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ cannot load library "opencv_java" 12-16 08:46:08.047 1838-1838/com.company.opencvsdktest w/system.err﹕ java.lang.unsatisfiedlinkerror: couldn't load opencv_java loader dalvik.system.pathclassloader[dexpathlist[[zip file "/data/app/com.company.opencvsdktest-1.apk"],nativelibrarydirectories=[/data/app-lib/com.company.opencvsdktest-1, /vendor/lib, /system/lib]]]: findlibrary returned null 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ java.lang.runtime.loadlibrary(runtime.java:358) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ java.lang.system.loadlibrary(system.java:529) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ org.opencv.android.statichelper.loadlibrary(statichelper.java:64) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ org.opencv.android.statichelper.initopencvlibs(statichelper.java:95) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ org.opencv.android.statichelper.initopencv(statichelper.java:39) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ org.opencv.android.opencvloader.initdebug(opencvloader.java:62) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ com.company.opencvsdktest.mainactivity.onresume(mainactivity.java:93) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.instrumentation.callactivityonresume(instrumentation.java:1194) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activity.performresume(activity.java:5315) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread.performresumeactivity(activitythread.java:2804) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread.handleresumeactivity(activitythread.java:2843) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread.handlelaunchactivity(activitythread.java:2278) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread.access$800(activitythread.java:138) 12-16 08:46:08.055 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread$h.handlemessage(activitythread.java: 1236) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.os.handler.dispatchmessage(handler.java:102) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.os.looper.loop(looper.java:149) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ android.app.activitythread.main(activitythread.java:5045) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ java.lang.reflect.method.invokenative(native method) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ java.lang.reflect.method.invoke(method.java:515) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ com.android.internal.os.zygoteinit.main(zygoteinit.java:602) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest w/system.err﹕ @ dalvik.system.nativestart.main(native method) 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest d/opencv/statichelper﹕ first attempt load libs fails 12-16 08:46:08.063 1838-1838/com.company.opencvsdktest e/opencv﹕ unable load opencv 12-16 08:46:08.211 1838-1838/com.company.opencvsdktest d/openglrenderer﹕ enabling debug mode 0
do have sdk? did need compile first? or should work automatically? provided have ndk installed, shouldn't have do other steps mentioned here: http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_ocv_on_android.html#application-development-with-static-initialization right?
edit: tried different locations libs folder, such in project root directory , in opencvlibrary folder. neither worked.
edit 2: using manager apk works fine. glass, won't solution there's no way access play store!
to solve problem let try following steps:
take in application.mk , check if app_abi right configured. opencv samples use armeabi-v7a default target cpu architecture. in case, app deployed against arm64-v8a device. it's therefore try:
app_abi := all
... sure jni-libs built device.
set 'libs' folder new jnilibs (library jni *.so) in build.gradle file
_
sourcesets{ main { jni.srcdirs =[] jnilibs.srcdirs = ['src/main/libs'] # change project structure } }
Comments
Post a Comment