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();
}
}
Can you add some code please?
ok, I added
Where exactly in the code you call to takePicture function? Did you call it in the onCreate event?
I call it in a function that is called from onCameraFrame (a function of CvCameraViewListener)
What devices did you tried?
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.