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
/optfolder 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/javaand wait for the sync to complete. - Create a folder named
jniLibsinsrc/mainand copy the content of<opencv_android_folder>/sdk/native/libsinto it. It will copy alibopencv_java4.sofile 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
pathToOpenCVto your OpenCV path.