我認爲這些最新版本應該兼容。有這個推文; 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這與問題無關,你應該先搜索某人是否有此問題或者提出自己的問題。 –