5

I want to load BufferedImage in my application. For that I am using ImageIO but I am getting java.lang.NoClassDefFoundError:

BufferedImage tgtImg = loadImage("ImageD2.jpg"); 
public static BufferedImage loadImage(String ref) { 
    BufferedImage bimg = null; 
    try { 
        bimg = ImageIO.read(new File(ref)); 
    } catch (Exception e) { 
        e.printStackTrace(); 
    } 
    return bimg; 
}

but i am getting exception:

03-15 18:05:22.051: ERROR/AndroidRuntime(437): java.lang.NoClassDefFoundError: javax.imageio.ImageIO
CodingGorilla
  • 19,612
  • 4
  • 45
  • 65
Monali
  • 1,966
  • 12
  • 39
  • 59
  • I am trying to load bufferedimage as :' BufferedImage tgtImg = loadImage("ImageD2.jpg"); public static BufferedImage loadImage(String ref) { BufferedImage bimg = null; try { bimg = ImageIO.read(new File(ref)); } catch (Exception e) { e.printStackTrace(); } return bimg; } but i am getting exception : 03-15 18:05:22.051: ERROR/AndroidRuntime(437): java.lang.NoClassDefFoundError: javax.imageio.ImageIO Please help me – Monali Mar 15 '11 at 12:39
  • @user437833, you should _edit_ your _question_, by _edit_ not _answer_. By the way, put 4 spaces before a line will make it _code_. You can see that effect in the preview. – Dante May Code Mar 15 '11 at 12:57

1 Answers1

11

ImageIO is not supported in Android SDK

Could you achieve the same thing with Bitmap and BitmapFactory?? like so...

Bitmap tgtImg = BitmapFactory.decodeFile("ImageD2.jpg");

if tgtImg is not null after this then it was successful.

Will Tate
  • 33,439
  • 9
  • 77
  • 71