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

  • SEARCH
  • Home
  • 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 7889053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:59:51+00:00 2026-06-03T05:59:51+00:00

I am using the JavaCV library with pre-built OpenCV libraries for Android. I think

  • 0

I am using the JavaCV library with pre-built OpenCV libraries for Android. I think I have setup Eclipse the right way, because I have included the jars both javacv.jar and javacpp.jar. In addition, the java-cv-android-arm.jar, in my project. Everything compiles fine, no errors, warning, anything that should be suspicious of something that will go wrong at runtime. But I get NoClassDefFOundError exception that is thrown in this method body below:

@Override
    public void draw(Canvas canvas)
    {
    try
    {
        canvas.drawColor(Color.BLUE);
        if (current != null)
        {
        int width = current.getWidth();
        int height = current.getHeight();
        IplImage i = IplImage.create(width, height, IPL_DEPTH_8U, 1); // I assume here is where the exception gets thrown
        ByteBuffer buffer = i.getByteBuffer();
        current.copyPixelsToBuffer(buffer);
        // We need a grayscale image in order to do the recognition, so
        // we
        // create a new image of the same size as the original one.
        IplImage grayImage = IplImage.create(i.width(), i.height(),
            IPL_DEPTH_8U, 1);
        // We convert the original image to grayscale.
        cvCvtColor(i, grayImage, CV_BGR2GRAY);
        CvMemStorage storage = CvMemStorage.create();
        // We instantiate a classifier cascade to be used for detection,
        // using the cascade definition.
        CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(
            cvLoad("haarcascade_frontalface_alt.xml"));
        // We detect the faces.
        CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage,
            1.1, 1, 0);
        // We iterate over the discovered faces and draw yellow
        // rectangles around them.
        for (int index = 0; index < faces.total(); index++)
        {
            CvRect r = new CvRect(cvGetSeqElem(faces, index));
            cvRectangle(i, cvPoint(r.x(), r.y()),
                cvPoint(r.x() + r.width(), r.y() + r.height()),
                opencv_core.CvScalar.YELLOW, 1, CV_AA, 0);
        }
        Bitmap b = BitmapFactory.decodeByteArray(i.getByteBuffer()
            .array(), 0, i.getByteBuffer().array().length);
        canvas.drawBitmap(b, x, y, paint);
        canvas.drawText(new Date().toLocaleString(), canvas.getWidth() - 100,
            canvas.getHeight() - 50, paint);
        paint.setColor(Color.GREEN);
        }
    } catch (Exception e)
    {
        canvas.drawColor(Color.RED);

        canvas.drawText(
            "Handled exception occurred in panel:\n" + e.getMessage(),
            250, 250, paint);
        paint.setColor(Color.GREEN);
    }
    super.draw(canvas);
    }

And of course, right after the exception is thrown, my Android crashes, and I force close the application. Did I include the jars, and required libraries correctly? Is there anything that I should be aware of? Any help would be greatly appreciated.

Here is the LogCat for those who love Cats (insert emoticon here):

05-03 19:07:53.217: E/AndroidRuntime(741): FATAL EXCEPTION: main
05-03 19:07:53.217: E/AndroidRuntime(741): java.lang.NoClassDefFoundError: com.googlecode.javacv.cpp.opencv_core$IplImage
05-03 19:07:53.217: E/AndroidRuntime(741):  at home.security.DrawingPanel.draw(DrawingPanel.java:81)
05-03 19:07:53.217: E/AndroidRuntime(741):  at home.security.Main$2.run(Main.java:105)
05-03 19:07:53.217: E/AndroidRuntime(741):  at android.os.Handler.handleCallback(Handler.java:587)
05-03 19:07:53.217: E/AndroidRuntime(741):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-03 19:07:53.217: E/AndroidRuntime(741):  at android.os.Looper.loop(Looper.java:123)
05-03 19:07:53.217: E/AndroidRuntime(741):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-03 19:07:53.217: E/AndroidRuntime(741):  at java.lang.reflect.Method.invokeNative(Native Method)
05-03 19:07:53.217: E/AndroidRuntime(741):  at java.lang.reflect.Method.invoke(Method.java:507)
05-03 19:07:53.217: E/AndroidRuntime(741):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-03 19:07:53.217: E/AndroidRuntime(741):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-03 19:07:53.217: E/AndroidRuntime(741):  at dalvik.system.NativeStart.main(Native Method)

Folder Structure Of ‘libs Folder

enter image description here

  • 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-03T05:59:53+00:00Added an answer on June 3, 2026 at 5:59 am

    The jars need to be in the project-root/libs folder or to mark them as exported in the build path of the project…

    now it should work…

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

Sidebar

Related Questions

Using JavaCV. I have a 2 sets of CvPoint2D32f points in an ArrayList one
I have done Android and C development in my copy of Eclipse, but have
I have the opposite problem as Upgrade Eclipse java compiler : I'm using Eclipse
I'm using JavaCv with OpenCv 2.3 from Java (on Windows). Occasionally something goes wrong,
I'm using Eclipse along with plugin m2eclipse to build and manage my project. In
I am having the same issues as in This question: Android unit test using
I am using Ant > 1.8 + Proguard 4.6 to build my Android project
I am trying to compile a library I wrote, using javac and I am
I have a Android project which I'm building in Ant and I'm stuck on
I'm working on a small library for our in-company use, and have been heavily

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.