Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Picasso not loading images

I have been using Picasso for quite some time, but I had to upgrade OkHttp library to 2.0.0 and, consequently, I had to upgrade Picasso to version 2.3.2.

However, now Picasso does not load any image at all, the imageviews are left empty. No error shows up at any time, but when I turned Picasso logging on, the "Hunter" seems to be dispatched and starts executing, but never finishes.

All the images are accessible and rather small (around 200px by 100px).

I'm loading the images through Picasso's "typical" method:

Picasso.with(context).load(url).error(R.drawable.errorimg).into(imageView);

However, the errorimg is never shown.

What could I be doing wrong?

EDIT:

Here is the code of one of the places where Picasso is not working (PlaceListAdapter.java - getView function)

public View getView(int position, View convertView, ViewGroup parent) 
{
    final PBNPlace ev = values.get(position);

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.places_list_item, parent, false);

    TextView titleView = (TextView)rowView.findViewById(R.id.place_title);
    ImageView placeImage = (ImageView)rowView.findViewById(R.id.place_image);

    Picasso picasso = Picasso.with(context);
    picasso.load(ev.imageURL).error(R.drawable.chat).into(placeImage);

    titleView.setText(ev.name);

    return rowView;
}
like image 248
Sagito Avatar asked Sep 30 '22 09:09

Sagito


2 Answers

When you upgraded OKHttp, did you also upgrade the okhttp-urlconnection dependency?

I had this issue and it turned out I was still calling for version 1.6.0 of okhttp-urlconnection in my build.gradle file. There were no error messages that made it readily apparent to me that I had overlooked this.

Changing that to 2.0.0 solved the problem.

like image 69
Ben O Avatar answered Oct 04 '22 20:10

Ben O


Picasso does not have an HTTP client inside of it so saying that is "supports HTTPS" means little.

When you pass in a url (whether it has a scheme of http:// or https://) we pass that along to the most appropriate HTTP client there is.

Maybe that's java.net.HttpURLConnection. Maybe it's that sexy bundle of bytecode OkHttp. The bottom line is that whatever the scheme is we just let the HTTP client handle it.

Any problems you are having with http:// vs https:// are in the configuration of the client, not Picasso.

Said By JakeWharton

So for loading images you just need to add below dependencies in your gradle file.

compile 'com.squareup.okhttp:okhttp:2.2.+'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.+'
compile 'com.squareup.picasso:picasso:2.5.2'

Reference : https://github.com/square/picasso/issues/500

like image 24
KishuDroid Avatar answered Oct 04 '22 19:10

KishuDroid