charlesfranciscodev charlesfranciscodev - 1 year ago 139
Android Question

How to use Stetho with okhttp3 for network inspection?

I launched the app the Android emulator (Genymotion). Problem is I cannot inspect anything in Chrome Dev Tools (see screenshot below). Any tips ?


Google Chrome Dev Tools in (address bar)

This is what I see after entering this URL in Chrome

Chrome Dev Tools

import android.content.Context;

import com.facebook.stetho.Stetho;

public class TrainerWorkoutApplication extends Application {
public void onCreate() {

} // onCreate()

} // TrainerWorkoutApplication

package com.trainerworkout.trainerworkout.activity;


/** As a personal trainer I need to log in so that I can have access to the app. */
public class LogInActivity extends AppCompatActivity {
public static OkHttpClient client;
private OkHttpClient.Builder builder = new OkHttpClient.Builder();

protected void onCreate(Bundle savedInstanceState) {
// ...
builder.addInterceptor(new AddCookiesInterceptor(context));
builder.addInterceptor(new ReceivedCookiesInterceptor(context));

builder.addNetworkInterceptor(new StethoInterceptor());

client =;
} // onCreate()


} // LogInActivity

build.gradle (app)

apply plugin: ''

android {
} // android

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile ''
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile ''
compile ''
compile ''
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
} // dependencies

Answer Source

To fix this, I think the Application class should be in the application package and not in the java package. Also, make sure the application class is declared in the


<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.trainerworkout.trainerworkout"

enter image description here

For more info on how to use Stetho I recommend this tutorial.

Debugging Android Apps with Facebook's Stetho

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download