Based on OpenCV's Tutorial #1.
Based on this
- Download latest OpenCV sdk for Android from OpenCV.org and decompress the zip file.
- Import OpenCV to Android Studio, From File -> New -> Import Module, choose sdk/java folder in the unzipped opencv archive.
- Update build.gradle under imported OpenCV module to update 4 fields to match your project build.gradle a) compileSdkVersion b) buildToolsVersion c) minSdkVersion and 4) targetSdkVersion.
- Add module dependency by Application -> Module Settings, and select the Dependencies tab. Click + icon at bottom, choose Module Dependency and select the imported OpenCV module.
- For Android Studio v1.2.2, to access to Module Settings : in the project view, right-click the dependent module -> Open Module Settings
- Copy libs folder under sdk/native to Android Studio under app/src/main.
- In Android Studio, rename the copied libs directory to jniLibs and we are done.
Download and install Android's Native Development Kit (NDK). More info here: https://developer.android.com/ndk/guides/setup.html
This project uses the gradle experimental plugin, so it is subject to change.
Your local.properties
file must define the ndk and opencv dirs. Here's mine as an example
sdk.dir=~/Library/Android/sdk
ndk.dir=/usr/local/android-ndk-r10e
opencv.dir=~/dev/androidstudio/OpenCV-android-sdk/sdk/native/jni/include