Ask Your Question

Problem loading the jni lib with OCV Manager

asked 2012-11-06 10:20:12 -0500

Simone gravatar image

updated 2012-11-06 16:57:52 -0500


I had a simple app for LK tracking that was basically built following and slightly the "Tutorial 2 - mix Java+Native" of a older version of OCV (2.3.x i think). So now I'm trying to update the application in order to use it with the 2.4.3.

I succesfully managed to slightly change the code so i can use the 2.4.3 in a static way. Now I'd like to go further and update it to use the OCV Manager. Here come the problems. :(

Let me first recall that the architecture of the app is exactly the same as the old sample i mentioned before, so we have 3 files, with the main TrackingActivity, the TrackerBase Class with the threaded structure and the Tracker derived class that implements the method to be called whenever a frame is available.

I removed all the code for static loading and added the new way of interacting with the manager to the main activity

public class TrackingActivity extends Activity 
private BaseLoaderCallback  mLoaderCallback = new BaseLoaderCallback(this) {  
    public void onManagerConnected(int status) 
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
                Log.i(TAG, "OpenCV loaded successfully");

                // Load native library after(!) OpenCV initialization

            } break;
                Log.e(TAG, "problem loading OCV?");
            } break;
protected void onResume()
    // TODO Auto-generated method stub
    if( !OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback) )
        Log.e(TAG, "Cannot connect to OpenCV Manager");

So far so good. I also changed all the .mk files to resemble those of the official documentation and of the new samples of OCV 2.4.3. When i tried to execute the application (both on real devices and on the AVD) the OpenCV Manager is connected succefully and then when it comes to


I get this exception

11-06 14:46:31.224: I/Tracking::Activity(1461): OpenCV loaded successfully
11-06 14:46:31.224: D/dalvikvm(1461): Trying to load lib /data/data/com.example.lktracker/lib/ 0x412a4d98
11-06 14:46:31.224: D/AndroidRuntime(1461): Shutting down VM
11-06 14:46:31.224: W/dalvikvm(1461): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
11-06 14:46:31.244: E/AndroidRuntime(1461): FATAL EXCEPTION: main
11-06 14:46:31.244: E/AndroidRuntime(1461): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]:    36 cannot locate '_ZN2cv12_OutputArrayD1Ev'...
11-06 14:46:31.244: E/AndroidRuntime(1461):     at java.lang.Runtime.loadLibrary(
11-06 14:46:31.244: E/AndroidRuntime(1461):     at java.lang.System.loadLibrary(
11-06 14:46:31.244: E/AndroidRuntime(1461):     at fr.lab.gipsa.lktracker.TrackingActivity$1.onManagerConnected(
11-06 14:46:31.244: E/AndroidRuntime(1461):     at$1.onServiceConnected(
11-06 14:46:31.244: E/AndroidRuntime(1461):     at$ServiceDispatcher.doConnected(
11-06 14:46:31.244: E/AndroidRuntime(1461):     at$ServiceDispatcher$
11-06 ...
edit retag flag offensive close merge delete


Ok my bad... I was actually using the trunk version of OCV to build while on the devices i still had the OCV 2.4.3 binary version. As soon as i made everything coherent with the binary version it worked.

Simone gravatar imageSimone ( 2012-11-07 04:36:12 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-11-25 00:40:11 -0500

Be careful with different branches of OpenCV. Branch 2.4 and Master are not binary compatible. Mixing code from different branches may case different linker errors in compile time or in run time.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-11-06 10:20:12 -0500

Seen: 675 times

Last updated: Dec 14 '12