{"id":7742,"date":"2015-10-19T01:17:40","date_gmt":"2015-10-19T01:17:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/19\/retrofit-1-9-with-okhttp-2-2-and-interceptors-open-source-projects-square-okhttp\/"},"modified":"2015-10-19T01:17:40","modified_gmt":"2015-10-19T01:17:40","slug":"retrofit-1-9-with-okhttp-2-2-and-interceptors-open-source-projects-square-okhttp","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/19\/retrofit-1-9-with-okhttp-2-2-and-interceptors-open-source-projects-square-okhttp\/","title":{"rendered":"Retrofit 1.9 with OkHttp 2.2 and interceptors-open source projects square\/okhttp"},"content":{"rendered":"<p>I thought that these recent versions were supposed to be compatible. There is this tweet; https:\/\/twitter.com\/JakeWharton\/status\/553066921675857922 and the changelog of Retrofit 1.9 mentions it too.<\/p>\n<p>However when I try this:<\/p>\n<pre><code>        OkHttpClient httpClient = new OkHttpClient();\n        httpClient.interceptors().add(new TokenExpiredInterceptor());\n\n        mRestAdapter = new RestAdapter.Builder()\n                .setEndpoint(API_ENDPOINT)\n                .setClient(httpClient)\n                .setLogLevel(BuildConfig.DEBUG ?\n                        RestAdapter.LogLevel.FULL :\n                        RestAdapter.LogLevel.NONE)\n                .setRequestInterceptor(new AuthorizationInterceptor())\n                .build();\n<\/code><\/pre>\n<p>It still doesn&#8217;t work. The setClient method complains about an incompatible Client object;<\/p>\n<pre><code>Error:(29, 21) error: no suitable method found for setClient(OkHttpClient)\nmethod Builder.setClient(Client) is not applicable\n(argument mismatch; OkHttpClient cannot be converted to Client)\nmethod Builder.setClient(Provider) is not applicable\n(argument mismatch; OkHttpClient cannot be converted to Provider)\n<\/code><\/pre>\n<p>What am I missing? I also see OkHttpClient does not implement the Client interface.<\/p>\n<p>I am using this approach for now; https:\/\/medium.com\/@nullthemall\/execute-retrofit-requests-directly-on-okhttp-2-2-7e919d87b64e<\/p>\n<p>Did I misinterpret the changelog? Maye Retrofit 1.9 can uses OkHttpClient 2.2 when it&#8217;s in the classpath but the interface isn&#8217;t adapted yet?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I thought that these recent versions were supposed to be compatible. There is this tweet; https:\/\/twitter.com\/JakeWharton\/status\/553066921675857922 and the changelog of Retrofit 1.9 mentions it too. However when I try this: 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(); It still doesn&#8217;t work. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7742","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7742"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7742\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}