6

我在我的项目中使用Retrofit-1.6.0+ 。okhttp-2.0.0-RC1当我运行项目时,我得到了错误。

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!

有人知道如何解决这个问题吗?

4

3 回答 3

13

即使使用 OkHTTP 2,您也需要额外导入 urlConnection

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

于 2014-07-24T16:08:50.053 回答
8

好的,Square 已经在 github 上发布了 2.0 RC2,但在 maven 上没有:

https://github.com/square/okhttp

但是你仍然需要 okhttp-urlconnection (RC1),它只在 maven 上:

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

别忘了 okhttp 2.0 现在依赖于 okio:

https://github.com/square/okio

于 2014-06-09T14:34:32.107 回答
2

我有 picasso/Retrofit 和你一样抱怨。此配置对我有用:

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'
于 2015-07-01T11:38:33.453 回答