OkHTTP and Picasso don't run together

前端 未结 6 1984
灰色年华
灰色年华 2020-12-05 18:40

I use Picasso library in my project to load images ande cache them. It works good without any problem. However, when I try to use OkHttp library to perform data communicatio

相关标签:
6条回答
  • 2020-12-05 19:05
    //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.

    0 讨论(0)
  • 2020-12-05 19:05

    Try these:

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp3:okhttp:3.0.1'
    
    0 讨论(0)
  • 2020-12-05 19:05

    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.

    0 讨论(0)
  • 2020-12-05 19:15

    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.

    0 讨论(0)
  • 2020-12-05 19:16

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

    0 讨论(0)
  • 2020-12-05 19:21

    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'
    
    0 讨论(0)
提交回复
热议问题