NoClassDefFoundError in android 2.3.6 version(HttpResponseCahe)

510 Views Asked by At

I developed one Android app it's working fine in 4.0 and above but when it comes to version 2.3.4 it giving an exception about Responcecache. I followed according to github:- https://github.com/candrews/HttpResponseCache.I'm getting below an exception running in 2.3.4 and 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)

How to resolve this issue please help me.

2

There are 2 best solutions below

2
On

As the exception stacktrace specifies it is a NoClassDefFoundError

It occurs when the source was successfully compiled but at runtime, the required class files were not found.

Since you developed it in 4.0, At that time the specific classes were available, and your app ran succesfully.

And now you are trying to run the compiled app in the lower versions i.e 2.3.4 and 2.3.6, So here those classes may not be available, so JVM is throwing that error

Only thing you have to do is add the required jar files to your app, and try running it.

0
On

Please have a look at this thread.

In library httpresponsecache-1.3.jar use disklrucache-1.2.1.jar

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

Here is the GitHub associated to DiskLruCache project: https://github.com/JakeWharton/DiskLruCache

You can download the suitable revision here: https://repository.sonatype.org