Closed antonkrasov closed 9 years ago
You need to pass the client (with interceptors) into the RestAdapter Builder: setClient(new OkClient(okHttpClient)) should read: setClient(client)
@fingertricks, that's exactly how it works. I just use dagger, so client just returned from @Provides method. And Injects as okHttpClient. I can't use setClient(client), as Retrofit requires OkClient, inside it I can pass my custom OkHttpClient.
Are you using Retrofit <= 1.8? According to https://github.com/square/okhttp/wiki/Interceptors, it won't work on that older version without some additional effort.
The Interceptors he is using were not available in Retrofit 1.8.
I'm having the same issue. In the logs I see:
W/System.err﹕ java.io.IOException: Address already in use
W/System.err﹕ at android.net.LocalSocketImpl.bindLocal(Native Method)
W/System.err﹕ at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:303)
W/System.err﹕ at android.net.LocalServerSocket.
@antonkrasov let me spin up a quick Retrofit 1.9 + OkHttp 2.2.0 sample app to see if I can debug through the problems locally.
@Tremelune that error is unrelated (but still a bug). It's a harmless issue but is unintentionally noisy. I'll fix it soon.
@jasta wow, thanks! I really forgot to update Retrofit, updated OkHttp to 2.2.0, but continue using Retrofit 1.7.0
Same issue, with OkHttp 2.2.0 and Retrofit 1.9.
@Tremelune, seems like I need to reopen then.
@Tremelune I tested this locally and cannot see an issue with Retrofit 1.9. Can you try adding the logging interceptor mentioned in https://github.com/square/okhttp/wiki/Interceptors. I'm curious if that is working. If no, I think your issue is just with interceptors in general.
Yup, I'll see what I can do. I'm hoping for the ol' "clean build" fix...
Updating Retrofit to 1.9.0 didn't help, trying to add logging interceptor.
@jasta LoggingInterceptor from https://github.com/square/okhttp/wiki/Interceptors works fine for me. But Network tab still doesn't show anything.
I confirmed my sample app is working correctly with Retrofit 1.9 and OkHttp 2.2.0. Source is here: https://github.com/jasta/retrofit-okhttp-stetho-demo
Here's the modified GitHubClient
: https://github.com/jasta/retrofit-okhttp-stetho-demo/blob/master/app/src/main/java/com/example/retrofit/GitHubClient.java
Screenshot to prove it :)
@jasta cloning your demo app :) will check it now
@jasta yeah, your demo app works for me. Hmm, let me compare with my project and try to find the reason.
@jasta Wooohoo, thank you :) I found the issue, and it's quite simple: Proguard.
I fixed this for my project by adding:
-keep class com.facebook.stetho.**{ *; }
W/System.err﹕ java.io.IOException: Address already in use
W/System.err﹕ at android.net.LocalSocketImpl.bindLocal(Native Method)
W/System.err﹕ at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:254)
W/System.err﹕ at android.net.LocalServerSocket.<init>(LocalServerSocket.java:52)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.bindToSocket(LocalSocketHttpServer.java:278)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.listenOnAddress(LocalSocketHttpServer.java:138)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.run(LocalSocketHttpServer.java:134)
W/System.err﹕ at com.facebook.stetho.Stetho$1.run(Stetho.java:80)
Just run https://github.com/jasta/retrofit-okhttp-stetho-demo
Hi Guys,
First of all, thanks for your job, great project! I'm trying to setup Stetho, but I don't see any network calls in Network tab.
Here is my OkHttpClient initialization:
Then I create RestAdapter with this client
I use 2.2.0:
This is in my Application class:
If I open console I see "Powered by Stetho", but I don't see any network calls. But Retrofit display full logs fine.
What I'm doing wrong? :) Thanks.