做个 条形码识别  要用 java.awt.image.BufferedImage;      javax.imageio.ImageIO;   导入C:\Program Files\Java\jdk1.6.0_10\jre\lib\rt.jar   后,编译能通过,但是运行就找不到了。请各位大侠指教啊,日志如下05-30 18:34:16.220: D/dalvikvm(2915): GC_EXTERNAL_ALLOC freed 66K, 49% free 2793K/5379K, external 127K/523K, paused 73ms
05-30 18:34:17.791: I/System.out(2915): path 2==/mnt/sdcard/Pictures/CameraSample/IMG_20120530_183417_1184166436.jpg
05-30 18:34:17.791: I/System.out(2915): first
05-30 18:34:17.791: I/System.out(2915): src 1==/mnt/sdcard/Pictures/CameraSample/IMG_20120530_183417_1184166436.jpg
05-30 18:34:17.791: I/dalvikvm(2915): Could not find method javax.imageio.ImageIO.read, referenced from method barcode.EAN13Reader.EAN13Reader.getImg
05-30 18:34:17.791: W/dalvikvm(2915): VFY: unable to resolve static method 112: Ljavax/imageio/ImageIO;.read (Ljava/io/File;)Ljava/awt/image/BufferedImage;
05-30 18:34:17.791: D/dalvikvm(2915): VFY: replacing opcode 0x71 at 0x0006
05-30 18:34:17.791: W/dalvikvm(2915): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
05-30 18:34:17.791: D/dalvikvm(2915): VFY: dead code 0x0009-0009 in Lbarcode/EAN13Reader/EAN13Reader;.getImg (Ljava/lang/String;)Ljava/awt/image/BufferedImage;
05-30 18:34:17.791: W/dalvikvm(2915): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
05-30 18:34:17.791: I/dalvikvm(2915): Could not find method java.awt.image.BufferedImage.getWidth, referenced from method barcode.EAN13Reader.EAN13Reader.getRealValue
05-30 18:34:17.791: W/dalvikvm(2915): VFY: unable to resolve virtual method 85: Ljava/awt/image/BufferedImage;.getWidth ()I
05-30 18:34:17.791: D/dalvikvm(2915): VFY: replacing opcode 0x74 at 0x0000
05-30 18:34:17.791: D/dalvikvm(2915): VFY: dead code 0x0003-0138 in Lbarcode/EAN13Reader/EAN13Reader;.getRealValue (Ljava/awt/image/BufferedImage;)Ljava/lang/String;
05-30 18:34:17.801: I/System.out(2915): second
05-30 18:34:17.801: I/System.out(2915): src 2==/mnt/sdcard/Pictures/CameraSample/IMG_20120530_183417_1184166436.jpg
05-30 18:34:17.801: D/AndroidRuntime(2915): Shutting down VM
05-30 18:34:17.801: W/dalvikvm(2915): threadid=1: thread exiting with uncaught exception (group=0x4007a568)
05-30 18:34:17.811: E/AndroidRuntime(2915): FATAL EXCEPTION: main
05-30 18:34:17.811: E/AndroidRuntime(2915): java.lang.NoClassDefFoundError: javax.imageio.ImageIO
05-30 18:34:17.811: E/AndroidRuntime(2915):  at barcode.EAN13Reader.EAN13Reader.getImg(EAN13Reader.java:194)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at barcode.capture.TestProjectActivity.eanRecog(TestProjectActivity.java:236)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at barcode.capture.TestProjectActivity.access$4(TestProjectActivity.java:229)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at barcode.capture.TestProjectActivity$2.onClick(TestProjectActivity.java:285)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.view.View.performClick(View.java:2486)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.view.View$PerformClick.run(View.java:9130)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.os.Handler.handleCallback(Handler.java:587)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.os.Looper.loop(Looper.java:130)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at android.app.ActivityThread.main(ActivityThread.java:3703)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at java.lang.reflect.Method.invokeNative(Native Method)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at java.lang.reflect.Method.invoke(Method.java:507)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-30 18:34:17.811: E/AndroidRuntime(2915):  at dalvik.system.NativeStart.main(Native Method)
05-30 18:34:19.203: I/Process(2915): Sending signal. PID: 2915 SIG: 9

解决方案 »

  1.   

    LZ用的ADT是什么版本的,ADT17以后的jar包要放在libs文件夹下,让后再build path到项目.不然的话就会发生这个错误.
    还有一种是你jar包的排序问题.我就遇到过着两种情况,不知道能不能帮助你.
      

  2.   

    查了好多资料都说android不能用awt包。。换了bitmap中的方法了
    二楼能说下 jar包排序 是怎么弄的不?
      

  3.   

    就是导入import android.graphics.Bitmap; import android.graphics.BitmapFactory;      AWT包中的方法你可以在Bitmap中找到对应的方法,
     public Bitmap binarization(Bitmap img) {  
             int width = img.getWidth();  
             int height = img.getHeight();  
                     
    }private void setPic() {//缩小图片 /* There isn't enough memory to open up more than a couple camera photos */
    /* So pre-scale the target bitmap into which the file is decoded */ /* Get the size of the ImageView */
    int targetW = mImageView.getWidth();
    int targetH = mImageView.getHeight(); /* Get the size of the image */
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
    int photoW = bmOptions.outWidth;
    int photoH = bmOptions.outHeight;
    //System.out.println("photoW=="+photoW);
    //System.out.println("photoH=="+photoH);

    /* Figure out which way needs to be reduced less */
    int scaleFactor = 2;
    if ((targetW > 0) || (targetH > 0)) {
    scaleFactor = Math.min(photoW/targetW, photoH/targetH);
    } /* Set bitmap options to scale the image decode target */
    bmOptions.inJustDecodeBounds = false;
    bmOptions.inSampleSize = scaleFactor;
    bmOptions.inPurgeable = true; /* Decode the JPEG file into a Bitmap */
    Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);

    /* Associate the Bitmap to the ImageView */
    mImageView.setImageBitmap(bitmap);

    mImageView.setVisibility(View.VISIBLE);

    }