view raw
Kishu Agarwal Kishu Agarwal - 10 months ago 94
Android Question

Okhttp NoClassDefFoundError

I am using OkHttp 2.0.0 jar in my android application on eclipse. As OkHttp is now dependent on Okio library, I also added Okio 1.0.0 jar in my project.The project compiles fine with no compilation errors but when I run on my android device, it gives me this

all relating to the OkHttp library classes.

I have placed all the jars in my libs folder of the project and added them to my build path and also tried checking them in the Export and Order Tab, but still it is not working.

I wanted to know since okhttp is dependent on okio, will just adding both jars would work fine or would I have to do anything different.

I have also tried the volley jar and it works all fine without any trouble.Anyone could help me out here, the problem is around for now 3 to 4 days.

I also tried the android studio and added the okhttp library in the build dependency but still not working.


In OkHttp 2.0.0 the language level was updated to Java 7.

See Change log here

In order to fix the issue you will need to update to java 7.

Also at this point you may also need change the target sdk to kitkat (API 19), and update your build tools etc in order for android to play nice with java 7

EDIT: I had the same problem when i upgraded to okHttp 2.0.0 and built with ant. Although the build seemed to succeed i got the NoClassDefFoundError. Going through my build logs I had a whole bunch of silent errors

The first came from javac

warning: com/squareup/okhttp/<classname>.class major version 51 is newer than 50, the highest major version supported by this compiler.

and the second from dex

[dx] trouble processing:
[dx] bad class file magic (cafebabe) or version (0033.0000)
[dx] ...while parsing com/squareup/okhttp/<classname>.class
[dx] ...while processing com/squareup/okhttp/<classname>.class