【问题标题】:NoClassDefFoundError in android 2.3.6 version(HttpResponseCahe)android 2.3.6版本中的NoClassDefFoundError(HttpResponseCahe)
【发布时间】:2014-01-29 01:04:08
【问题描述】:

我开发了一个 Android 应用程序,它在 4.0 及更高版本中运行良好,但在 2.3.4 版本中它给出了关于 Responcecache 的异常。我按照github:-https://github.com/candrews/HttpResponseCache。我遇到了在2.3.4和2.3.6中运行的异常。

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.jakewharton.DiskLruCache
at com.integralblue.httpresponsecache.compat.libcore.net.http.HttpResponseCache.<init>(HttpResponseCache.java:83)
at com.geeklabs.footmark.util.HttpResponseUtil.enableHttpResponseCache(HttpResponseUtil.java:41)
com.integralblue.httpresponsecache.HttpResponseCache.install(httpCacheDir, httpCacheSize);
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

如何解决这个问题,请帮助我。

【问题讨论】:

  • 看起来你还没有添加库
  • @Bhargav Methuku - 你得到解决方案了吗?
  • @user3110424 你的意思是哪个库.....

标签: java android caching classnotfoundexception httpresponsecache


【解决方案1】:

由于异常堆栈跟踪指定它是NoClassDefFoundError

当源编译成功但在运行时找不到所需的类文件时发生。

由于你是在4.0开发的,那个时候具体的类都可以了,你的app运行成功了。

现在您正尝试在较低版本(即 2.3.4 和 2.3.6)中运行已编译的应用程序,因此这些类可能不可用,因此 JVM 会抛出该错误

您只需将所需的 jar 文件添加到您的应用中,然后尝试运行它。

【讨论】:

  • 包括 httpresponsecache jar 及其依赖项 DiskLruCache。
  • @BhargavMethuku -yes disklrucache.jar
【解决方案2】:

请查看this thread

在库 httpresponsecache-1.3.jar 中使用 disklrucache-1.2.1.jar

在 disklrucache-1.2.1.jar 中,包是:com.jakewharton,但在 2.0.2 版中,包已更改 > 为 com.jakewharton.disklrucache

这里是与 DiskLruCache 项目相关的 GitHub:https://github.com/JakeWharton/DiskLruCache

你可以在这里下载合适的版本:https://repository.sonatype.org

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    相关资源
    最近更新 更多