It seems you already have imported the opencv module, now, open your CMakeList.txt and add the follow lines:
set(CMAKE_VERBOSE_MAKEFILE on)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION
path-to-your-project/MyApplication/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)
include_directories(path-to-opencv-directory/OpenCV-android-sdk/sdk/native/jni/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
and edit the:
target_link_libraries( # Specifies the target library.
native-lib
lib_opencv
# Links the target library to the log library
# included in the NDK.
$\{log-lib} )
to include your lib_opencv that you have created. To finish, you add the follow line:
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
in your module app, like this:
externalNativeBuild {
cmake {
cppFlags "-std=c++11 -frtti -fexceptions"
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
}
}
and below of buildTypes you add:
sourceSets {
main {
jniLibs.srcDirs = ['path to your application /MyApplication/app/src/main/jniLibs/']
}
}
For more details, you can see this: https://github.com/googlesamples/android-ndk/tree/master/cmake/hello-libs