Android Picasso Image does not load

62,205

Solution 1

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.

Solution 2

check Internet permission in manifaest

<uses-permission android:name="android.permission.INTERNET"/>

Solution 3

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.

Solution 4

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);

Solution 5

You can use Picasso.with(Context).setLoggingEnabled(true) to enable debugging so as to troubleshoot the exact cause . If the log has something like Error 504 try using:

android:usesCleartextTraffic="true"

in Application tag of your manifest. It worked for me

Answered here

Share:
62,205
xosuma
Author by

xosuma

Updated on July 18, 2022

Comments

  • xosuma
    xosuma almost 2 years

    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.

  • xosuma
    xosuma over 8 years
    Interesting, I'll definitely try out. Thanks for your time!
  • xosuma
    xosuma over 8 years
    Thanks for the info, def. worth out of all!
  • Sam
    Sam almost 7 years
    this post has helped me to load image from storage. thanks!
  • Dita Aji Pratama
    Dita Aji Pratama over 5 years
    Omg, thats a simple answer
  • Jayce
    Jayce almost 5 years
    Same thing here (on 7/25/19) .. Picasso wouldn't load the image, but glide does. Not sure why.
  • TheRealChx101
    TheRealChx101 almost 5 years
    Do you know how to centercrop without specifying the width and height? Glide does it automatically but Picasso requires you to provide the values.
  • TheRealChx101
    TheRealChx101 almost 5 years
    In my case I have a vector drawable and Picasso is still not loading it. Dumped it for Glide.
  • TheRealChx101
    TheRealChx101 almost 5 years
    Yes. Glide even has extra methods like loading byter arrays etc. Good for loading from database without manually decoding the Bitmap yourself.
  • MikeL
    MikeL almost 5 years
    I think this has changed to Picasso.get().setLoggingEnabled(true)
  • Infomaster
    Infomaster about 3 years
    Yes, Must be put "IP Address" NOT localhost
  • matteoh
    matteoh almost 3 years
    the android:usesCleartextTraffic="true" only did the trick for me.