我用毕加索库在我的项目中加载图像,安德缓存。它的工作原理很好,没有任何问题。然而,当我尝试使用OkHttp库来执行我的服务器(JSON通信)的数据通信,毕加索抛出异常。
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 communication with my server (JSON communication), Picasso throws exceptions.
我用下面的罐子:okhttp-2.0.0-RC2,奥基奥-1.0.0,毕加索-2.2.0。当我运行我的项目后,我添加这些罐子,它崩溃并出现以下内容:
I use the following jars : okhttp-2.0.0-RC2, okio-1.0.0, picasso-2.2.0. When I run my project after I add these jars, It crashes with the following :
06-12 11:13:15.824: E/dalvikvm(12105): Could not find class 'com.squareup.okhttp.HttpResponseCache', referenced from method com.squareup.picasso.OkHttpDownloader.<init>
我添加okhttp只是为了使用下面的方法:
I added okhttp just to use the following method :
public static String executeHttpGet(String urlStr) {
Response response = null;
String result = "";
OkHttpClient client = new OkHttpClient();
try {
Request request = new Request.Builder().url(urlStr).build();
response = client.newCall(request).execute();
result = response.body().string();
} catch (Exception ex) {
}
return result;
}
以上code工作没有任何问题。然而,codeS它们使用毕加索库,并用来很好地工作,开始引发以下excecption:
The above code works without any problem. However the codes which use Picasso library and used to work perfectly, start to throw the following excecption :
06-12 11:19:49.307: E/AndroidRuntime(13036): FATAL EXCEPTION: main
06-12 11:19:49.307: E/AndroidRuntime(13036): java.lang.NoClassDefFoundError: com.squareup.okhttp.HttpResponseCache
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:74)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:51)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:41)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.Utils$OkHttpLoaderCreator.create(Utils.java:319)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.Utils.createDefaultDownloader(Utils.java:171)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.Picasso$Builder.build(Picasso.java:490)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.Picasso.with(Picasso.java:390)
我的类路径:
My Class Path :
如果我删除okhttp-2.0.0-RC2,奥基奥-1.0.0,毕加索线工作。
If I remove okhttp-2.0.0-RC2, okio-1.0.0, Picasso lines work.
这是为什么发生?如何使用两个库一起?
Why is that happening ? How can I use two libraries together ?
推荐答案
切换到毕加索2.3.2。您还需要okhttp-的URLConnection-2.0.0-RC2。
Switch to Picasso 2.3.2. You'll also need okhttp-urlconnection-2.0.0-RC2.
相关推荐
最新文章