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
I was facing the same error, I resized the same image and uploaded it to firebase then load its URL using picasso and this time it worked totally fine; image was loaded successfully.
Same image was not showing nor there were any picasso logs before it was resized.
It took me almost two days to realise that real issue was with image size. I resized my image to 500x500 and everything worked fine.
NOTE: In my case I was capturing image from device's camera then uploading it to firestore and then loading image using picasso. So to fix the issue I started to resize image in onActivityResult()
method then save resized image to local storage and uploaded it to firestore.
Don't know its relevant to this issue or not but my problem is solved by using Glide instead of Picasso.
Use link below
Picasso.Get().Load(imageUri).Placeholder(Resource.Drawable.patient_profile_pic).Resize(100, 100).Into(imgProflle);
Xamarin or .Net
byte[] imageBytes;
using (var webClient = new WebClient())
{
imageBytes = webClient.DownloadData(imageUri);
}
Bitmap bitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
imgProflle.SetImageBitmap(bitmap);
I had faced the same issue but below is the solution which is worked for me.
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.3.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
===============================================================================
private static Picasso picasso = null;
public static Picasso.Builder picassoBuilder ;
public static void loadImageInto(Context context, String url, int width, int
height, Target target) {
initPicasso(context);
picasso.load(url)
.error(android.R.drawable.stat_notify_error)
.resize(width, height)
.centerCrop()
.into(target);
}
public static void initPicasso(Context context) {
if (picasso == null) {
picassoBuilder = new Picasso.Builder(context);
try {
Picasso.setSingletonInstance(picasso);
} catch (IllegalStateException ignored) {
// Picasso instance was already set
// cannot set it after Picasso.with(Context) was already in use
}
picassoBuilder.downloader(new OkHttpDownloader(new OkHttpClient())).memoryCache(Cache.NONE).loggingEnabled(true).indicatorsEnabled(true);
picasso = picassoBuilder.build();
}
}