1

in my application i want to use this below pasted code as PicassoCache, but after use that such as :

PicassoCache.getPicassoInstance(context)
                .load(list.get(position).getStoreImage())
                .placeholder(R.drawable.ic_messages)
                .into(holder.store_avatar);

i get this error:

Could not find class 'com.squareup.okhttp.CacheControl$Builder', referenced from method com.squareup.picasso.OkHttpDownloader.load
06-12 01:13:17.484 6246-6246/ir.pishguy.signalpresentationproject E/AndroidRuntime: FATAL EXCEPTION: 

main java.lang.NoClassDefFoundError: com.squareup.okhttp.OkHttpClient

PicassoCache:

import com.squareup.picasso.Downloader;
import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;

public class PicassoCache {

    private static Picasso picassoInstance = null;
    private PicassoCache(Context context) {

        Downloader      downloader = new OkHttpDownloader(context, Integer.MAX_VALUE);
        Picasso.Builder builder    = new Picasso.Builder(context);
        builder.downloader(downloader);

        picassoInstance = builder.build();
    }

    public static Picasso getPicassoInstance(Context context) {

        if (picassoInstance == null) {

            new PicassoCache(context);
            return picassoInstance;
        }
        return picassoInstance;
    }
}

My gradle:

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'android-command'
apply plugin: 'realm-android'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "ir.pishguy.signalpresentationproject"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    command {
        events 2000
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}

ext {
    supportLibVersion = '23.4.0'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:support-v4:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile('io.socket:socket.io-client:0.7.0')
            {
                // excluding org.json which is provided by Android
                exclude group: "org.json", module: "json"
            }

    compile ('com.squareup.retrofit2:retrofit:2.0.2'){
        exclude module:'okhttp'
    }
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.github.devlight.navigationtabbar:library:+'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile "de.hdodenhof:circleimageview:2.0.0"
    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    compile "com.balysv:material-ripple:1.0.2"
    compile 'com.github.traex.rippleeffect:library:1.3'
    compile 'com.github.chyrta:AndroidOnboarder:+'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:multidex:1.0.1'
}
DolDurma
  • 15,753
  • 51
  • 198
  • 377

2 Answers2

0

Try the following combination, it's working for me :

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

Hope it will work for you :)

Neo
  • 3,546
  • 1
  • 24
  • 31
0

For me combination

// Retrofit
compile('com.squareup.retrofit2:retrofit:2.0.2') {
    exclude module: 'okhttp'
}
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
// Picasso
compile 'com.squareup.picasso:picasso:2.5.2'

works well, but here some answers said that

compile 'com.squareup.okhttp:okhttp-urlconnection:x.x.x'

may help.

Community
  • 1
  • 1
user35603
  • 765
  • 2
  • 8
  • 24