在Eclipse中导入Picasso和OkHttp [英] Importing Picasso and OkHttp in Eclipse
问题描述
应用程序首次尝试制作Picasso请求时,我收到以下异常:
04-12 17:04:15.956:E / AndroidRuntime(5436):java.lang.NoClassDefFoundError:com.squareup.okhttp.internal.DiskLruCache $ 4
04-12 17:04:15.956 :E / AndroidRuntime(5436):at com.squareup.okhttp.internal.DiskLruCache。< clinit>(DiskLruCache.java:810)
04-12 17:04:15.956:E / AndroidRuntime(5436) at com.squareup.okhttp.Cache。< init>(Cache.java:168)
04-12 17:04:15.956:E / AndroidRuntime(5436):at com.squareup.picasso.OkHttpDownloader。< ; init>(OkHttpDownloader.java:77)
04-12 17:04:15.956:E / AndroidRuntime(5436):com.squareup.picasso.OkHttpDownloader。< init>(OkHttpDownloader.java:55)
04-12 17:04:15.956:E / AndroidRuntime(5436):com.squareup.picasso.OkHttpDownloader。< init>(OkHttpDownloader.java:45)
04-12 17:04 :15.956:E / AndroidRuntime(5436):在com.squareup.picasso.Utils $ OkHttpLoade rCreator.create(Utils.java:424)
04-12 17:04:15.956:E / AndroidRuntime(5436):在com.squareup.picasso.Utils.createDefaultDownloader(Utils.java:250)
04-12 17:04:15.956:E / AndroidRuntime(5436):at com.squareup.picasso.Picasso $ Builder.build(Picasso.java:832)
04-12 17:04:15.956:E / AndroidRuntime(5436):at com.squareup.picasso.Picasso.with(Picasso.java:662)
指定的类似乎在jar中,但DiskLruCache.java似乎分为9个类文件:
$ ls DiskLruCache *
DiskLruCache $ 1.class DiskLruCache $ 4.class DiskLruCache $ Entry.class
DiskLruCache $ 2.class DiskLruCache $ Editor $ 1.class DiskLruCache $ Snapshot.class
DiskLruCache $ 3.class DiskLruCache $ Editor .class DiskLruCache.class
我准备提供额外的信息。任何建议将被高度赞赏。
编辑:
在OkHttp jar中我试图将其导入主要项目以及毕加索jar(最新 - 2.5.2),我也得到了同样的例外。我没有看到任何OkHttp警告,表示与其他线程中所述的不兼容。
OkHttp需要 Okio 上班。这是在 GitHub页面上提到的,位于下载按钮下面。导入Okio jar修复了NoClassDefFoundError。以下是我刚刚测试的工作配置:
毕加索:2.5。 2 ; okhttp:2.3.0 ; okio:1.3.0 。
I need to expose some Picasso resources to satisfy a rather strange request. For this I need to import Picasso as a library project instead of a compiled jar. I've created a new Android Project and copied the contents of picasso\picasso\src\main\java (cloned master) to the src folder. Picasso uses OkHttp so I downloaded the latest release jar (2.3.0) and put it in the libs folder of the Picasso project; added it to the build path; selected the jar in the build path "Order and Export" preferences. Finally, I made the Picasso project a library and included it in the main project (also removed the old Picasso jar from libs).
The first time the application tries to make a Picasso request I get the following exception:
04-12 17:04:15.956: E/AndroidRuntime(5436): java.lang.NoClassDefFoundError: com.squareup.okhttp.internal.DiskLruCache$4
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.okhttp.internal.DiskLruCache.<clinit>(DiskLruCache.java:810)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.okhttp.Cache.<init>(Cache.java:168)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:77)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:55)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:45)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.Utils$OkHttpLoaderCreator.create(Utils.java:424)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.Utils.createDefaultDownloader(Utils.java:250)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.Picasso$Builder.build(Picasso.java:832)
04-12 17:04:15.956: E/AndroidRuntime(5436): at com.squareup.picasso.Picasso.with(Picasso.java:662)
The specified class seems to be in the jar but DiskLruCache.java seems broken into a total of 9 class files:
$ ls DiskLruCache*
DiskLruCache$1.class DiskLruCache$4.class DiskLruCache$Entry.class
DiskLruCache$2.class DiskLruCache$Editor$1.class DiskLruCache$Snapshot.class
DiskLruCache$3.class DiskLruCache$Editor.class DiskLruCache.class
I'm ready to provide additional info. Any advice would be highly appreciated.
Edit:
The problem seems to be in the OkHttp jar. I've tried to import it in the main project along with the Picasso jar (latest - 2.5.2) and I get the same exception. I do not see any OkHttp warnings, indicating incompatibility as stated in some other threads.
OkHttp requires Okio to work. This is mentioned on the GitHub page, right under the download button. Importing the Okio jar fixed the NoClassDefFoundError. Here's a working configuration that I just tested: picasso:2.5.2; okhttp:2.3.0; okio:1.3.0.
这篇关于在Eclipse中导入Picasso和OkHttp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!