13

The code:

URL url = new URL(bitmapurl);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
     connection.setDoInput(true);
      connection.connect();
 InputStream input = connection.getInputStream();

bitmap[i] = BitmapFactory.decodeStream(input);
System.out.println("the bitmap is +bitmap[i]);

Error in Logcat:

03-29 15:01:50.044: DEBUG/skia(238): --- SkImageDecoder::Factory returned null
the bitmap is null

How can this problem be solved?

Roger Lindsjö
  • 11,330
  • 1
  • 42
  • 53
tamil
  • 322
  • 2
  • 8
  • 21
  • I think that it can randomly pop up when there are connection problems. I stumbled into this randomly with the same image, where it would work most of the time and only sometimes fail. So it can't be anything related to the image, must be the network or something. – mxk Sep 08 '11 at 12:50
  • it's not a duplicate.... WITCH! – user123321 Feb 02 '12 at 18:30
  • In other post i read this an solved my problem: http://stackoverflow.com/questions/9188002/skimagedecoderfactory-returned-null – Fernando May 30 '12 at 16:02
  • Go to other questions now, and accept the top-most answer, to provide expected feedback to the SO community. – Marek Sebera Jun 30 '12 at 16:14
  • @tamil Have you solved it? – hemanth kumar Apr 01 '14 at 06:59
  • This is not a duplicate as was alleged, as it does not involve the re-use which was the cause of the problem in the other question. However, it's questionable if the problem is still current. – Chris Stratton May 13 '14 at 15:09

1 Answers1

8

Check that the URL is indeed an image, and not a HTML file. Had this frustrating issue and then I realized I had attempted to download a bitmap over a WiFi hotspot... which required me to log in first. Your saved image is probably the HTML file that shows when you need to log in!

Before saving it, check the first few bytes to make sure it is a PNG, XML, JPG, whatever.

albnok
  • 521
  • 2
  • 14