Getting NoClassDefFoundError for nMatToBitmap2 on some devices

asked 2013-12-19 06:13:33 -0600

Asaf gravatar image

updated 2013-12-22 01:42:10 -0600

I have an Android application on Google Play that uses OpenCV. I use OpenCV's matToBitmap to save images from the camera. OpenCV's native files are included in the project. I use Flurry to be informed of crashes. Many crashes were with this trace:

java.lang.NoClassDefFoundError
org.opencv.android.Utils.nMatToBitmap2(Native Method)
org.opencv.android.Utils.matToBitmap(Unknown Source)
                         matToBitmap
org.opencv.android.Utils.matToBitmap(Unknown Source)
                         matToBitmap
org.opencv.android.CameraBridgeViewBase.processEnterState(Unknown Source)
                                        deliverAndDrawFrame
                                        disconnectCamera
                                        calculateCameraFrameSize
org.opencv.android.JavaCameraView$CameraWorker.run(Unknown Source)
java.lang.Thread.run(Thread.java:1019)
Caused by: dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
org.opencv.android.Utils.nMatToBitmap2(Native Method)
org.opencv.android.Utils.matToBitmap(Unknown Source)
                         matToBitmap
org.opencv.android.Utils.matToBitmap(Unknown Source)
                         matToBitmap
org.opencv.android.CameraBridgeViewBase.processEnterState(Unknown Source)
                                        deliverAndDrawFrame
                                        disconnectCamera
                                        calculateCameraFrameSize
org.opencv.android.JavaCameraView$CameraWorker.run(Unknown Source)
java.lang.Thread.run(Thread.java:1019)

It happened in these devices, all of which with API 10:

Samsung Galaxy Ace (GT-S5830)
ZTE Groove X501
Samsung Galaxy Ace 2 
LG Optimus L3 (E400) 
LG Optimus NET DUAL (P698F)
Samsung Galaxy Mini (GT-S5570L) 
LG Optimus Q/Aloha

I would be happy to know what could cause this problem, and if it's possible to fix it.

Thanks.

code sample:

public void takePicture(Mat picture){
    Bitmap bitmap;
    bitmap = Bitmap.createBitmap(picture.width(), picture.height(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(picture, bitmap);
    try
    {
        createThumbnailAndSave(bitmap, createPicTimeStr());
        bitmap.recycle();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
edit retag flag offensive close merge delete

Comments

Can you add some code please?

itay gravatar imageitay ( 2013-12-19 08:02:37 -0600 )edit

ok, I added

Asaf gravatar imageAsaf ( 2013-12-22 01:40:28 -0600 )edit

Where exactly in the code you call to takePicture function? Did you call it in the onCreate event?

itay gravatar imageitay ( 2013-12-23 03:15:43 -0600 )edit

I call it in a function that is called from onCameraFrame (a function of CvCameraViewListener)

Asaf gravatar imageAsaf ( 2013-12-23 09:28:59 -0600 )edit

What devices did you tried?

itay gravatar imageitay ( 2013-12-24 00:10:47 -0600 )edit

I listed the devices on which the error occurred in my initial post, to which have been recently added Sony Xperia GO and Android S930 (running android version 4.03). On all other devices (almost 400 types) it didn't happen.

Asaf gravatar imageAsaf ( 2013-12-24 01:49:55 -0600 )edit