1

In the method below I download and store an image in the internal storage. Strangely this has worked fine for about 2 months until today when I suddenly started to receive this text for each image in the logcat.

SkImageDecoder::Factory returned null

Which I didn't get before. After that "error" the image is empty. I've tried these answers from similar questions:

Android: SkImageDecoder:: Factory returned null

how to get bitmap information and then decode bitmap from internet-inputStream?

How to solve the SkImageDecoder::Factory returned null

SkImageDecoder::Factory returned null

But none of these works. Does anyone have any idea of why this suddenly happens?

public String storeImage(Context ctx, String url) {
    String fileName = String.valueOf(Calendar.getInstance().getTimeInMillis());
    try {
        if (url != null) {
            URL request = new URL(url);
            InputStream is = new BufferedInputStream(request.openStream());
            BufferedInputStream bis = new BufferedInputStream(is);
            ByteArrayBuffer baf = new ByteArrayBuffer(5000);
            int current = 0;
            while ((current = bis.read()) != -1) {
                baf.append((byte) current);
            }
            is.close();
            FileOutputStream fos = ctx.openFileOutput(fileName, Context.MODE_PRIVATE);
            fos.write(baf.buffer());
            fos.close();
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return fileName;
}
Community
  • 1
  • 1
just_user
  • 11,769
  • 19
  • 90
  • 135

0 Answers0