gpt4 book ai didi

android - NoClassDefFoundError: android.graphics.YuvImage(编译但不运行)

转载 作者:行者123 更新时间:2023-11-29 18:21:51 25 4
gpt4 key购买 nike

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

我遇到的问题是 eclipse 说有一个关于我正在使用的 YuvImage 的 classnotfoundexception。我已经下载了 yuvimage 所属的 api8。源代码中没有错误,编译正常。 ecilipse 无法加载 yuvimage 类有什么原因吗?这是一个 fragment ,谢谢。

'代码'

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 中右键单击您的项目,选择 Properties,然后选择 Android。应选择 Api 8 作为项目的构建目标。

您还应该在 list xml 中设置最小 SDK 属性(尽管这与错误无关)。

关于android - NoClassDefFoundError: android.graphics.YuvImage(编译但不运行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4956876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com