我认为这些最新版本应该兼容。有这个推文; https://twitter.com/JakeWharton/status/553066921675857922和改造日志1.9也提到了它。用OkHttp 2.2和拦截器改造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方法抱怨一个不兼容的Client对象;
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没有实现客户端界面。
我现在正在使用这种方法; https://medium.com/@nullthemall/execute-retrofit-requests-directly-on-okhttp-2-2-7e919d87b64e
我误解了更改日志吗? Maye Retrofit 1.9可以在类路径中使用OkHttpClient 2.2,但界面不适用?
谢谢!不能相信我错过了:p – dzan
@UsAfzal这与问题无关,你应该先搜索某人是否有此问题或者提出自己的问题。 –