java – Static Initialization on OpenCV Android-ThrowExceptions

Exception or error:

i’m trying to run OpenCV Tutorial 1 – Add OpenCV with static initialization using this
i don’t want a separate OpenCV Manager application installed) but i get an "OpenCV error: Cannot load info library for OpenCV."

I did the following things:

  1. added a libs folder with armeabi, armeabi-v7a, and x86 folders inside of it (from OpenCV-2.4.2-android-sdk/sdk/native/libs/)

  2. added the static {if (!OpenCVLoader.initDebug())} code just below private Sample1View mView;

  3. removed the below code

if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this,

what seems to be the problem?

How to solve:

You should add the code:



if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) 

If you remove:

if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))  

code block then nobody calls.

Hope it can help you.


I have the same problem, I have solved the problem by adding the following code at the first of my Activity class:

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error

Also I added


before the line

OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback); 

and commented the line

OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);

Good luck.


The log message:

"OpenCV error: Cannot load info library for OpenCV."

shuld not worry you. At least in my app it tells me something like OpenCV libs init is OK afterwards.

In the sample code the CameraBridgeViewBase object gets enabled when the BaseLoaderCallback gets called. That happens when the async loading of the opencv library has finished.
When you load the library statically, try adding a call to mOpenCVCameraView.enableView() in your onResume() method (after loading the lib of coourse).


initAsync() needs a callback to load opencv libs and your jni libs.

check the callback function and make it right in the if (!OpenCVLoader.initDebug()), not in the callback!

            if (!OpenCVLoader.initDebug()) {
            // Handle initialization error
              Log.i(TAG, "OpenCV load not successfully");
        } else {



it works for the tutorial 2 in OCV4Android2.4.5.

Leave a Reply

Your email address will not be published. Required fields are marked *