Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Picasso Image does not load

There are two situations I load images, first, just directly from the internet, and second, load images that are downloaded in the device. And whenever I load, 8~9 out of 10 images are shown, and 1-2 missing. I see that decode returned false, and google'd as hard as I can, but couldn't come up.

  1. WAIT_FOR_CONCURRENT_GC blocked 22ms
  2. WAIT_FOR_CONCURRENT_GC blocked 20ms
  3. GC_FOR_ALLOC freed 718K, 31% free 9948K/14256K, paused 49ms, total 51ms
  4. D/skia: --- decoder->decode returned falseGC_CONCURRENT freed 1370K, 30% free 10081K/14256K, paused 3ms+2ms, total 33ms
  5. GC_FOR_ALLOC freed 916K, 30% free 10029K/14256K, paused 66ms, total 67ms

Here's code I use to load through Picasso:

        Picasso.with(activity)
            .load(path)
            .placeholder(R.drawable.thumbnail_placeholder)
            .resize(width,height)
            .into(imageView);

Any ideas how to solve this issue? I am calling fit()/resize() every time I get the images to load on the screen. Help much appreciated, thanks in advance!

FYI, I test on both machines, emulator and the real device, Samsung Galaxy Tab 3, and works without any problems on emulator, but problems occur on real device.

UPDATE:

It was causing by image's color space, where images that weren't showing up were the ones that were in YMCK color space.

like image 481
xosuma Avatar asked Mar 16 '16 19:03

xosuma


People also ask

How do you load an image into an imageView from an image URL using Picasso?

Image loading using Picasso is very easy, you can do it like this way Picasso. get(). load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.

Which is better Picasso or glide Android?

Glide's loading times are faster and it uses a small amount of memory for cache, but the library size is quite large. It, too, is easy to implement. Glide might be a better alternative to Picasso when memory footprint is less of a concern or more and larger images need to be processed.


4 Answers

You can turn on Picasso logs using Picasso.with(Context).setLoggingEnabled(true). You will probably see an error message with a reason there.

It's also worth logging the URL you are using and trying it a browser, just in case.

like image 51
Matthew Shearer Avatar answered Oct 09 '22 16:10

Matthew Shearer


check Internet permission in manifaest

<uses-permission android:name="android.permission.INTERNET"/>
like image 41
Tarun Umath Avatar answered Oct 09 '22 16:10

Tarun Umath


Try to replace "http:" at the start of your Url with "https:" (if it applies)

(on your String representation of Url).replace("http:", "https:");

Works for me.

like image 14
Andrij Avatar answered Oct 09 '22 17:10

Andrij


In Picasso you shoud pass url in .load() method to load picture from internet and object of File type to load picture from device storage.

So if the picture is stored on device load it like this:

        Picasso.with(activity)
                .load(new File(path))
                .placeholder(R.drawable.thumbnail_placeholder)
                .resize(width,height)
                .into(imageView);

And use this code to load picture from internet:

        Picasso.with(activity)
                .load(path)
                .placeholder(R.drawable.thumbnail_placeholder)
                .resize(width,height)
                .into(imageView);
like image 10
dzikovskyy Avatar answered Oct 09 '22 16:10

dzikovskyy