java.lang.NoClassDefFoundError的与Htt的presponseCache和DiskLruCache [英] java.lang.NoClassDefFoundError with HttpResponseCache and DiskLruCache
问题描述
我正尝试在测试一个新的项目的Android这个缓存库。结果
当我运行该项目,我得到这个logcat的:
I´m trying test this cache Library in a new project Android.
When I run the project, I get this Logcat:
01-24 03:45:31.109: E/AndroidRuntime(1983): FATAL EXCEPTION: main
01-24 03:45:31.109: E/AndroidRuntime(1983): Process: com.test_cache, PID: 1983
01-24 03:45:31.109: E/AndroidRuntime(1983): java.lang.NoClassDefFoundError: com.jakewharton.DiskLruCache
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.integralblue.httpresponsecache.compat.libcore.net.http.HttpResponseCache.<init>(HttpResponseCache.java:83)
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.integralblue.httpresponsecache.HttpResponseCache.<init>(HttpResponseCache.java:155)
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.integralblue.httpresponsecache.HttpResponseCache.install(HttpResponseCache.java:192)
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.test_cache.MainActivity.onCreate(MainActivity.java:21)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.Activity.performCreate(Activity.java:5243)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.ActivityThread.access$700(ActivityThread.java:135)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.os.Handler.dispatchMessage(Handler.java:102)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.os.Looper.loop(Looper.java:137)
01-24 03:45:31.109: E/AndroidRuntime(1983): at android.app.ActivityThread.main(ActivityThread.java:4998)
01-24 03:45:31.109: E/AndroidRuntime(1983): at java.lang.reflect.Method.invokeNative(Native Method)
01-24 03:45:31.109: E/AndroidRuntime(1983): at java.lang.reflect.Method.invoke(Method.java:515)
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-24 03:45:31.109: E/AndroidRuntime(1983): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-24 03:45:31.109: E/AndroidRuntime(1983): at dalvik.system.NativeStart.main(Native Method)
我克雷格·安德鲁斯并复制从项目的Htt presponseCache两个罐子< A HREF =https://github.com/JakeWharton/DiskLruCache相对=nofollow> DiskLruCache由Jake沃顿在我的libs文件夹:结果
I copied both jars from projects HttpResponseCache by Craig Andrews and DiskLruCache by Jake Wharton in my libs folder:
这是我的MainActivity.java:
This is my MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
final File httpCacheDir = new File(getCacheDir(), "http");
try {
com.integralblue.httpresponsecache.HttpResponseCache.install(httpCacheDir, httpCacheSize);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我在其他线程读取汇入作业的顺序的问题,所以在订单&放大器;在Java构建路径导出选项卡,我把这个放在第一位:
结果
I read in other threads that it´s problem of the order, so in the Order & Export tab in the Java Build Path, I put this in first place:
我打扫proyect,重建并没有什么工作,问题仍然存在...结果
任何想法...??
I clean the proyect, rebuild and nothing work, the problem persist...
Any idea...??
感谢。
推荐答案
由于您使用的 disklrucache-2.0.2.jar 和 HTT presponsecache-1.3.jar
在库 HTT presponsecache-1.3.jar 使用 disklrucache-1.2.1.jar
在 disklrucache-1.2.1.jar 的包是: com.jakewharton 但是在2.0.2版本的包被更改为 com.jakewharton。 disklrucache
In disklrucache-1.2.1.jar the package is: com.jakewharton but in version 2.0.2 the package is changed to com.jakewharton.disklrucache
这是根本原因。
如果你想使用 disklrucache 你应该使用1.2.1版
If you wanna use disklrucache you should use version 1.2.1
您可以从这里下载//www.mediafire。 COM /下载/ e2q4vz7kdlwxxr3 / disklrucache-1.2.1.jar (的.jar)
You can download from here: http://www.mediafire.com/download/e2q4vz7kdlwxxr3/disklrucache-1.2.1.jar (.jar)
或源文件: https://www.mediafire.com/?933nqqe9j4227cc (的.jar )
or source file: https://www.mediafire.com/?933nqqe9j4227cc (.jar)
希望这可以帮助你。
这篇关于java.lang.NoClassDefFoundError的与Htt的presponseCache和DiskLruCache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!