Memo36 Memo36 - 5 months ago 41
Android Question

Which Okhttp.jar version should I use with retrofit-2.0.1.jar?

I'm using the latest version of Retrofit through Gradle, and it works like a charm (

compile 'com.squareup.retrofit2:retrofit:2.0.1'
).

I wanted to use the .jar version, so I can include the library directly inside my app: I downloaded the
retrofit-2.0.1.jar.


I got an error on
retrofit2.converter.gson.GsonConverterFactory
that was not found anymore. I include the
converter-gson-2.0.1.jar
, but now I have an error with Okhttp at runtime:

java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Okio;


I've tried
okhttp-3.0.1.jar
and
okhttp-3.2.0.jar
, but none of them correct the error...

Which .jar should I add to have the retrofit2 without any Gradle/maven dependencies?

My phone is on Android L, I think the problem might come from there.

Regarding all the subjects around that:


Answer

I use these dependencies in my project:

compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'

This pulls in the following modules:

okhttp-3.2.0
okio-1.6.0
retrofit-2.0.1
converter-gson-2.0.1
Comments