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方法引发了一个不兼容的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,但是界面还没有改编?
解决方法 您正在将OkhttpClIEnt传递给接受ClIEnt实现的RestAdapter.Builder. OkhttpClIEnt,仅在客户端实现中不使用,与Retrofit无关.您应该将OkhttpClIEnt传递给实现ClIEnt的OkClIEnt实例
.setClIEnt(new OkClIEnt(httpClIEnt))
OkhttpClIEnt httpClIEnt = new OkhttpClIEnt();httpClIEnt.interceptors().add(new TokenExpiredInterceptor());mRestAdapter = new RestAdapter.Builder() .setEndpoint(API_ENDPOINT) .setClIEnt(new OkClIEnt(httpClIEnt)) .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FulL : RestAdapter.LogLevel.NONE) .setRequestInterceptor(new AuthorizationInterceptor()) .build();总结
以上是内存溢出为你收集整理的android – 使用OkHttp 2.2和拦截器的Retrofit 1.9全部内容,希望文章能够帮你解决android – 使用OkHttp 2.2和拦截器的Retrofit 1.9所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)