I am trying to test OpenCV Android, on Android Studio, I am confused about how to include the NDK.
What I want to do is run the samples which come with OpenCV. Of the 6 samples provided I managed to run 4 successfully. The exceptions were face-detection and native-activity.
I suspect the reason is I have not set up my NDK correctly.
Googling I found a bunch of discussions but do not really understand them. This is my first time I am trying to work with both the NDK and OpenCV, and my Gradle understanding is limited.
I set an environment variable in my .bash_profile
export ANDROID_NDK=pathTo/android-ndk-r9
I do not understand how to get this to studio.
I see reference to jniFolder but do not understand what these are and should I care right now. Stackoverflow.com/questions/17767557
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniFolders = new HashSet<File>()
pkgTask.jniFolders.add(new File(projectDir, 'native-libs'))
}
What am I supposed to do with this paste at the end of my build.gradle file ?
In summation, my questions are.
- How do I get Android Studio to read the NDK variable ?
- What exactly are the jniFolders ?
- Is it enough just to paste at the end of my build.gradle file ?
Google Group Discussions on Gradle and NDK
For anyone coming across this this is how I resolved it apart from Xaviers anwser. First I read OVERVIEW.html which comes with the NDK, in the docs directory. I then compiled the .mk and .cpp files into an .so file. I did this inplace in the sample jni directory This created the .so file in the libs folder which I copied to the destination as given by Xavier.