I used A Beginner’s Guide to Setting up OpenCV Android Library on Android Studio as a guide to setup OpenCV in an Android Studio project. I have got the project to build and
I use this method to set opencv 4.1.0. This should work too for 4.1.1.
build.gradle file
if (!OpenCVLoader.initDebug()) {
OpenCVLoader.initDebug()
}
on either onResume or onCreateView lifecycle hook(the sample use onResume but I havent encounter any problem using it on onCreateView)
Update 1. How to check if opencv installed correctly
sdk and samples.samples folder and copy its .java and .xml file from color-blob-detection(This sample implement JavaCameraView) folder to our blank project. I think this faster than fully import the sample.note : Read the build.gradle file for more setup config. eg. splitting apk, ndk support etc.