Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting NoClassDefFoundError for nMatToBitmap2 on some devices

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.

Getting NoClassDefFoundError for nMatToBitmap2 on some devices

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();
    }
}