c++ - Getting OpenCV with NDK support to work in Android Studio -
i'm new opencv , android programming , want use opencv in project. i'm trying run opencv's 2nd tutorial in android studio following ndk error:
error:execution failed task ':opencvtutorial2mixedprocessing:compiledebugndk'.
ndk not configured. download ndk http://developer.android.com/tools/sdk/ndk/.then add ndk.dir=path/to/ndk in local.properties. (on windows, make sure escape backslashes, e.g. c:\ndk rather c:\ndk)
then looked @ internet , guys suggested should add these gradle.build file:
jnilibs.srcdirs = ['native-libs'] jni.srcdirs = [] //disable automatic ndk-build
after adding these works following error:
java.lang.unsatisfiedlinkerror: dalvik.system.pathclassloader[dexpathlist[[zip file "/data/app/org.opencv.samples.tutorial2-2/base.apk"],nativelibrarydirectories=[/data/app/org.opencv.samples.tutorial2-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libopencv_java3.so"
this gradle file:
apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion "23.0.1" defaultconfig { applicationid "org.opencv.samples.tutorial2" minsdkversion 21 targetsdkversion 23 ndk { modulename "mixed_sample" } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } sourcesets{main {jni.srcdirs = ['src/main/jni','src/main/jnilibs'] jnilibs.srcdirs = ['native-libs'] jni.srcdirs = [] //disable automatic ndk-build }} } dependencies { compile project(':opencvlibrary310') }
well, code pasted in comment says:
jni.srcdirs = [] //disable automatic ndk-build
you don't see first error because entire compiledebugndk
step skipped. means ndk side of application isn't built, means none of opencv libraries in apk, means java isn't able load them, hence couldn't find "libopencv_java3.so"
.
you need write bit of logic build c++ side of project. there couple of ways this, easiest of reference ndk samples document how build , use native code build.gradle. build.gradle file hello-libs place start project 3rd-party dependencies.
Comments
Post a Comment