在OKHttp 2.0中,Retrofit在类路径错误上检测到不受支持的OkHttp

 倒退淂磁带_628 发布于 2023-01-10 12:06

我在我的项目中使用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!

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

2 个回答
  • 即使使用OkHTTP 2,您也需要导入额外的urlConnection

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

    2023-01-10 12:08 回答
  • 好吧,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

    2023-01-10 12:12 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有