Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit detected an unsupported OkHttp on the classpath error in OKHttp 2.0

I am using Retrofit-1.6.0 + okhttp-2.0.0-RC1 in my project . when i run the project i get the error.

java.lang.RuntimeException: Retrofit detected an unsupported OkHttp on the classpath.
To use OkHttp with this version of Retrofit, you'll need:
1. com.squareup.okhttp:okhttp:1.6.0 (or newer)
2. com.squareup.okhttp:okhttp-urlconnection:1.6.0 (or newer)
Note that OkHttp 2.0.0+ is supported!

Anybody knows how to fix this?

like image 733
null pointer Avatar asked Jun 09 '14 13:06

null pointer


3 Answers

Even with OkHTTP 2 you need to import the urlConnection extra

compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'

like image 143
Dori Avatar answered Oct 11 '22 03:10

Dori


Ok, square has released 2.0 RC2 on github, but not on maven:

https://github.com/square/okhttp

But you still need okhttp-urlconnection (RC1) which is only on maven:

http://mvnrepository.com/artifact/com.squareup.okhttp

And don't forget okhttp 2.0 is now dependent on okio:

https://github.com/square/okio

like image 22
Kyle Jahnke Avatar answered Oct 11 '22 05:10

Kyle Jahnke


I had picasso/Retrofit complaning the same way you do. This configuration worked for me:

compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
like image 2
voghDev Avatar answered Oct 11 '22 03:10

voghDev