NoClassDefFoundError:android.graphics.YuvImage(编译但无法运行) [英] NoClassDefFoundError: android.graphics.YuvImage (compiles but doesn't run)

查看:184
本文介绍了NoClassDefFoundError:android.graphics.YuvImage(编译但无法运行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重新发布此问题,因为我不确定之前是否正确提出了该问题.:)我正在开发一个包含面部检测的应用程序.相机启动正常.在预览帧回调中,我实例化一个faceview对象(此类处理检测).此类只能检测位图中的人脸,但回调中的图像是YuvImage.我已经将图像压缩为jpeg,然后调用了将jpeg转换为位图的方法,因此检测可以正常进行.

i'm reposting this question because i'm not sure if i asked it correctly before.:) i'm working on an app that includes face detection. the camera boots up ok. within the preview frame callback i instantiate a faceview object (this class handles the detection). this class can only detect faces in a bitmap, but the image from the callback is a YuvImage. i've compressed the image to jpeg then called a method to convert that jpeg to a bitmap, so the detection will work.

我遇到的问题是日食表示我正在使用的YuvImage有一个classnotfoundexception.我已经下载了yuvimage属于其中的api8.源代码中没有错误,可以正常编译.为什么ecilipse无法加载yuvimage类?这是一个摘要,谢谢.

The problem i'm having is that eclipse is saying that there's a classnotfoundexception regarding the YuvImage that i'm using. i've downloaded the api8 which yuvimage is part of. there are no errors in the source code and it compiles ok. is there a reason why ecilipse can't load the yuvimage class? here's a snippet, thanks.

代码"

BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inPreferredConfig = Bitmap.Config.RGB_565;
Rect rectangle = new Rect(0, 0, width, height);
ByteArrayOutputStream bos = new ByteArrayOutputStream(imageData.length);
try{
    img = new YuvImage(imageData,ImageFormat.NV21,width,height,null);
}catch(Exception e){
    e.printStackTrace();
}
img.compressToJpeg(rectangle, 100, bos);
byte[] array = bos.toByteArray();


sourceImage = BitmapFactory.decodeByteArray(array, 0, array.length);

异常跟踪:

02-10 11:53:07.298: ERROR/dalvikvm(2364): Could not find class 'android.graphics.YuvImage', referenced from method com.tecmark.FaceView.<init>
02-10 11:53:07.468: ERROR/AndroidRuntime(2364): Uncaught handler: thread main exiting due to uncaught exception
02-10 11:53:07.473: ERROR/AndroidRuntime(2364): java.lang.NoClassDefFoundError: android.graphics.YuvImage
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at com.tecmark.FaceView.<init>(FaceView.java:60)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at com.tecmark.cameraView$1.onPreviewFrame(cameraView.java:111)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at android.hardware.Camera$EventHandler.handleMessage(Camera.java:395)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at android.os.Looper.loop(Looper.java:123)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at android.app.ActivityThread.main(ActivityThread.java:4363)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at java.lang.reflect.Method.invokeNative(Native Method)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at java.lang.reflect.Method.invoke(Method.java:521)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-10 11:53:07.473: ERROR/AndroidRuntime(2364):     at dalvik.system.NativeStart.main(Native Method)

推荐答案

请确保您定位到正确版本的SDK.在Eclipse中,右键单击您的项目,选择属性",然后选择"Android".应该选择Api 8作为项目的构建目标.

Make sure that you are targeting the proper version of the SDK. In Eclipse right click your project, select Properties and then Android. Api 8 should be selected as the project's build target.

您还应该在清单xml中设置最小的SDK属性(尽管与错误无关).

You should also set the minimum SDK attribute in the manifest xml (this has nothing to do with the error though).

这篇关于NoClassDefFoundError:android.graphics.YuvImage(编译但无法运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆