Android NDK is used with CMake to compile C/C++.
- Download the latest OpenCV Android library at https://opencv.org/releases.
- Extract the content of the zip file into a folder (in
/opt
folder on Linux for ex). - Import OpenCV as a module into your Android project by clicking on
File -> New -> Import Module…
. - Choose
<opencv_android_folder>/sdk/java
and wait for the sync to complete. - Create a folder named
jniLibs
insrc/main
and copy the content of<opencv_android_folder>/sdk/native/libs
into it. It will copy alibopencv_java4.so
file for each device architecture (arm64, x86, ...). - Look at src/main/build.gradle to add the OpenCV module as a dependency and configure cmake.
- Look at src/main/cpp/CMakeLists.txt to
add the OpenCV library to your native code. Edit the var
pathToOpenCV
to your OpenCV path.