OkHTTP and Picasso don't run together

扶醉桌前 提交于 2019-11-27 21:15:50

This combination works for me:

compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.picasso:picasso:2.4.0'

Switch to Picasso 2.3.2. You'll also need okhttp-urlconnection-2.0.0-RC2.

//Below code for Picasso initializing once for the app
private Picasso picasso;
private OkHttpClient okHttpClient;

okHttpClient = new OkHttpClient();
picasso = new Picasso.Builder(this)
                .downloader(new OkHttpDownloader(okHttpClient))
                .build();

//Below code to retrieve the images whereever required on the app
picasso.with(context).load(imageUrl).placeholder(R.drawable.ic_launcher)

The above code works fine for me.

Picasso uses 3 packages.

  1. Square.OkHttp
  2. Square.OkIO
  3. Square.Picasso

You want to add 2 times the OkHttp and OkIO package because of using the OkHttp library and the Picasso library.

The 2 packages are included in Picasso, you don't need to include the OkHttp library in your project.

Try these:

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.0.1'

If you're using eclipse IDE,in project properties->java build path->order and export (last tab) check the picasso library

I had the same errors. it worked for me, hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!