【发布时间】:2015-01-10 19:33:17
【问题描述】:
我认为这些最新版本应该是兼容的。有这条推文; https://twitter.com/JakeWharton/status/553066921675857922 和 Retrofit 1.9 的更新日志也提到了它。
但是当我尝试这个时:
OkHttpClient httpClient = new OkHttpClient();
httpClient.interceptors().add(new TokenExpiredInterceptor());
mRestAdapter = new RestAdapter.Builder()
.setEndpoint(API_ENDPOINT)
.setClient(httpClient)
.setLogLevel(BuildConfig.DEBUG ?
RestAdapter.LogLevel.FULL :
RestAdapter.LogLevel.NONE)
.setRequestInterceptor(new AuthorizationInterceptor())
.build();
还是不行。 setClient 方法抱怨客户端对象不兼容;
Error:(29, 21) error: no suitable method found for setClient(OkHttpClient)
method Builder.setClient(Client) is not applicable
(argument mismatch; OkHttpClient cannot be converted to Client)
method Builder.setClient(Provider) is not applicable
(argument mismatch; OkHttpClient cannot be converted to Provider)
我错过了什么?我还看到 OkHttpClient 没有实现 Client 接口。
我现在正在使用这种方法; https://medium.com/@nullthemall/execute-retrofit-requests-directly-on-okhttp-2-2-7e919d87b64e
我是否误解了更新日志? Maye Retrofit 1.9 可以在类路径中使用 OkHttpClient 2.2 但接口尚未适配?
【问题讨论】:
标签: android retrofit square okhttp