Static Linking of OpenCV with Android | Jay Rambhia’s Blog

Static Linking of OpenCV with Android

I have been working on this android application for long exposure shots and want to put it on Google Play Store. Since I have included OpenCV, the application needs OpenCV Manager to run. Now, this can be demotivating for the users to download another app to run my app. So I looked around and there’s a way to do the static linking of OpenCV modules. And, it’s pretty easy too.

OpenCV Application Development With Static Initialization

You just need to add following lines in file.

OPENCV_CAMERA_MODULES:=on # If you want Camera module

In Java, Add following in the static section of the Activity class.

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    else {
        System.loadLibrary("jni_part"); // load other native libraries

That’s it. Now, the application doesn’t require OpenCV Manager to run. Although, APK size increases due to installing the modules.

P.S. Static Initialization might be slowing down the opencv processing part.