Android Picasso Image does not load
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
xosuma
Updated on July 18, 2022Comments
-
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.
- WAIT_FOR_CONCURRENT_GC blocked 22ms
- WAIT_FOR_CONCURRENT_GC blocked 20ms
- GC_FOR_ALLOC freed 718K, 31% free 9948K/14256K, paused 49ms, total 51ms
- D/skia: --- decoder->decode returned falseGC_CONCURRENT freed 1370K, 30% free 10081K/14256K, paused 3ms+2ms, total 33ms
- 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 over 8 yearsInteresting, I'll definitely try out. Thanks for your time!
-
xosuma over 8 yearsThanks for the info, def. worth out of all!
-
Sam almost 7 yearsthis post has helped me to load image from storage. thanks!
-
Dita Aji Pratama over 5 yearsOmg, thats a simple answer
-
Jayce almost 5 yearsSame thing here (on 7/25/19) .. Picasso wouldn't load the image, but glide does. Not sure why.
-
TheRealChx101 almost 5 yearsDo you know how to centercrop without specifying the width and height? Glide does it automatically but Picasso requires you to provide the values.
-
TheRealChx101 almost 5 yearsIn my case I have a vector drawable and Picasso is still not loading it. Dumped it for Glide.
-
TheRealChx101 almost 5 yearsYes. Glide even has extra methods like loading byter arrays etc. Good for loading from database without manually decoding the Bitmap yourself.
-
MikeL almost 5 yearsI think this has changed to
Picasso.get().setLoggingEnabled(true)
-
Infomaster about 3 yearsYes, Must be put "IP Address" NOT localhost
-
matteoh almost 3 yearsthe
android:usesCleartextTraffic="true"
only did the trick for me.