Debugging with Stetho

suggest change

Add the following dependencies to your application.

compile 'com.facebook.stetho:stetho:1.5.0' 
compile 'com.facebook.stetho:stetho-okhttp3:1.5.0'

In your Application class’ onCreate method, call the following.

Stetho.initializeWithDefaults(this);

When creating your Retrofit instance, create a custom OkHttp instance.

OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
clientBuilder.addNetworkInterceptor(new StethoInterceptor());

Then set this custom OkHttp instance in the Retrofit instance.

Retrofit retrofit = new Retrofit.Builder()
    // ...
    .client(clientBuilder.build())
    .build();

Now connect your phone to your computer, launch the app, and type chrome://inspect into your Chrome browser. Retrofit network calls should now show up for you to inspect.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents