Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8155003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:32:22+00:00 2026-06-06T16:32:22+00:00

I want to use OpenCV 2.4.0 native code in Android 2.3.3. For that, I

  • 0

I want to use OpenCV 2.4.0 native code in Android 2.3.3. For that, I used NDK release-8 to build lib.so shared libraries using the ndk-build.cmd script on Windows 7. I used Eclipse to create a project and build the .apk file.

Here’s the problem, I get an UnsatisfiedLinkError exception thrown when I try to load the shared libraries using System.loadLibrary() in the Java code. I have tried doing the same thing with the hello-jni sample in NDK, and it works absolutely fine.

I followed instructions on this page for creating a project and for writing the Android.mk and Application.mk files.

Here’s my java code:

package my.package.ocvtest1
// import android.foo.bar statements

public class OCVTest1 extends Activity
{

    public void onCreate(Bundle savedInstance)
    {
        super.onCreate(Bundle savedInstance)
        // code to display strings returned by native functions
    }

    public native String funtionName1();
    public native String functionName2();

    static
    {
        System.loadLibrary("ocvtest1");
    }

}

Here’s the (Project dir)/jni/ocvtest1.c file which implement native functions:

#include <jni.h>

// Other header files and some global variables

jstring Java_my_package_ocvtest1_OCVTest1 (JNIEnv *ptr, jobject obj)
{
    // code here
}

jstring Java_my_package_ocvtest1_OCVTest1_functionName2 (JNIEnv *ptr, jobject obj)
{
    // code here   
}

// End of file

I’ve googled this problem and tried the solutions, and even after implementing those solutions I get this exception. Here’s all the things I’ve tried till now:

Used dynamic linking by copying the libopencv_java.so and the static *.a library files into the (Project dir)/libs and (Project dir)/obj/local folders and changed static block of java source code to

static
{
    System.loadLibrary("opencv_java");
    System.loadLibrary("ocvtest");
}

Used static linking by adding OPENCV_LIB_TYPE:=STATIC as below

include $(CLEAR_VARS)
OPENCV_LIB_TYPE:=STATIC
include (<Path to Opencv.mk>)

Included header file generated by executing javah.exe my.package.OCVTest1 in the command prompt while using dynamic linking.

Changed armeabi-v7a to armeabi for the abi version variable in Application.mk file.

For all the above changes, to make sure that the library files were loaded into the app’s lib folder, I executed

adb push <path to library on disk> <path to /lib in app> 

which copied the library files into the proper directory on the phone.

After trying all of this fixes, I’m still not able to resolve this exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:32:23+00:00Added an answer on June 6, 2026 at 4:32 pm

    Used dynamic linking by copying the libopencv_java.so and the static
    *.a library files into the (Project dir)/libs and (Project dir)/obj/local folders and changed static block of java source code to

    You have to copy only libopencv_java.so (*.a file is not needed) to (Project dir)/libs/armeabi-v7a.

    Also you have:

    public native String funtionName1();
    

    But in native c code there are only these functions:

    jstring Java_my_package_ocvtest1_OCVTest1 (JNIEnv *ptr, jobject obj) // mistake?
    jstring Java_my_package_ocvtest1_OCVTest1_functionName2 (JNIEnv *ptr, jobject obj)
    

    It seems that name of the first function is wrong.

    That should fix your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

javaCV is wrapper library that based on openCV. But I want to use it
I want use this 1 for using Bar code or QR code scanner. I
I'm using OpenCV 2.3.2 library downloaded from OpenCV trunk. I want to use setOpenGlDrawCallback
http://opencv.willowgarage.com/wiki/Android or http://code.google.com/p/javacv/ ? I am new to computer vision, and want to do
I'm interested in developing an android app that makes use of an OpenCV android
I want to use Android for a system I have in order to use
I am updating some older OpenCV code that was written in (I guess) an
I want to compile OpenCV with same zlib as I use for compilation of
I want to use Opencv 2.4.0 (beta2) together with EmguCV and MonoDevelop on my
I want to use BRIEF and ORB in OpenCV and in order to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.