Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve the SkImageDecoder::Factory returned null [duplicate]

Tags:

android

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?

like image 847
tamil Avatar asked Mar 29 '11 09:03

tamil


1 Answers

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.

like image 58
albnok Avatar answered Oct 18 '22 20:10

albnok