Stetho is a library for debugging Android applications, developed by Facebook (Meta) in 2014. The tool integrates into an application through a Gradle dependency and opens access to the internal state through Chrome DevTools. According to the facebook/stetho repository (2026), the library supports inspection of SQLite, Network, SharedPreferences, View Hierarchy and Dumpapp plugins.
Key takeaways
Stetho is a Java library that runs a local WebSocket server inside an Android application. Chrome DevTools connects to this server through an adb port, gaining access to the application's internal components: databases, network requests, preferences and the view hierarchy. All communication goes through the Chrome DevTools Protocol, which allows using standard browser tools without installing additional software.
The library consists of modules: stetho (core), stetho-okhttp (traffic interception through OkHttp), stetho-urlconnection (interception through HttpURLConnection) and stetho-js-rhino (support for JavaScript plugins). The core opens a UNIX socket to which Chrome connects through adb forward. Each inspector is implemented as a separate plugin registered when Stetho is initialized.
Stetho supports Android 4.4+ (API 19) and only works in debug builds. On devices with Android 11+, an explicit INTERNET permission is required in the manifest. The library is officially unsupported by Facebook since 2020, but the code remains open and is used in legacy projects. For new projects Google recommends Android Studio Profiler and Network Inspector.
Connection is done through a Gradle dependency with the debugImplementation flag so that Stetho only works in the debug build. Initialization happens in the Application.onCreate() method with a single Stetho.initializeWithDefaults(this) call. For the Network Inspector, integration with OkHttp through an Interceptor is required.
// build.gradle (app) — adding Stetho
dependencies {
debugImplementation 'com.facebook.stetho:stetho:1.6.0'
debugImplementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
}
// Initialization in the Application class
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
To intercept network requests through OkHttp, add StethoInterceptor to the interceptor chain. Stetho automatically logs the URL, request and response headers, status code and execution time. The data is displayed in the Network tab in Chrome DevTools after connecting to the device through chrome://inspect.
Network Inspector in Stetho displays all HTTP requests of the application in chronological order. For each request the following are available: method, URL, status code, request and response headers, request and response body (including JSON and binary data). The Preview tab shows the response body in a formatted view.
Chrome DevTools supports filtering requests by type (XHR, JS, CSS, Doc), status code and domain. The search field filters by URL and content. For mobile development it is useful to group requests by API domain and check the call sequence when testing application screens.
// OkHttp client with Stetho interceptor
OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor(new StethoInterceptor())
.build();
// Executing a request
Request request = new Request.Builder()
.url("https://api.example.com/users")
.build();
client.newCall(request).enqueue(callback);
Database Inspector in Stetho connects to the application's SQLite databases through Chrome DevTools. In the Resources → Web SQL tab all open databases, their tables and contents are displayed. Viewing the table structure, indexes and running arbitrary SQL queries is available.
In the Chrome DevTools console you can run SQL queries directly against the application database: SELECT, INSERT, UPDATE, DELETE. This is useful for clearing data before testing, verifying the correctness of migrations and manually fixing incorrect records without rebuilding the application. All changes are immediately visible on the device.
Dumpapp is Stetho's shell interface that allows running custom commands through adb. Dumpapp plugins are registered when Stetho is initialized and can export any application state: cache, settings, DI container state. Commands are executed as adb forward tcp:12345 localabstract:stetho_dumpapp.
A plugin implements the DumperContext interface and is registered through Stetho.initialize with a custom InspectorModules. The example below shows a plugin for dumping SharedPreferences: the data is serialized to JSON and output to the terminal through an adb command.
// Custom Dumpapp plugin for SharedPreferences
public class PrefsDumper implements DumperContext {
@Override
public String getName() {
return "prefs";
}
@Override
public void dump(DumperContext ctx) {
SharedPreferences sp = ctx.getContext()
.getSharedPreferences("app_prefs", Context.MODE_PRIVATE);
ctx.getStdout().println(sp.getAll().toString());
}
}
Android Studio provides built-in profiling tools: Network Profiler, Database Inspector and View Inspector, introduced in Android Studio 4.1+. Stetho was popular before these tools were introduced and remains relevant for projects that use OkHttp and require integration with Chrome DevTools.
| Criterion | Stetho | Android Studio Inspector |
|---|---|---|
| Installation | Gradle dependency | Built into the IDE |
| Network | Through OkHttp Interceptor | Automatic for API 26+ |
| SQLite | Chrome DevTools + SQL queries | Android Studio only |
| SharedPreferences | Yes (Dumpapp plugin) | No |
| View Hierarchy | Chrome DevTools Elements | Layout Inspector |
| Support | Community (legacy) | Official Google |
Stetho is justified in legacy projects where OkHttp is already used and the team is used to Chrome DevTools. For new projects Android Studio Inspector covers most debugging scenarios. However, Chrome DevTools is still more convenient for SQLite queries: the built-in console with SQL autocompletion is faster than sequential clicks in the IDE.
View Hierarchy in Stetho is displayed in the Elements tab of Chrome DevTools as a DOM-like tree. Each View is represented as an HTML element with attributes: id, layout_width, layout_height, padding, margin, visibility and text. Changes in the tree are synchronized in real time on screen rotation or UI updates.
By selecting an element in the tree, you can view its properties on the Styles panel — similar to inspecting web pages. Stetho displays computed sizes, paddings, background color and state (pressed, focused, enabled). Changing some properties in DevTools is immediately applied to the application, which speeds up selecting UI parameters without rebuilding.
Stetho helps detect memory leaks related to View: if an Activity is not destroyed after finish(), its root View remains in the tree. By regularly checking the Elements tab you can notice phantom Activities and find the leak source — usually static references to Context or unclosed dialogs.
Stetho is effective for checking JSON serialization before sending it to the server. Open the Network Inspector, find the request and view the body in Raw mode to check the data structure and correctness of the fields.
Stetho displays all databases created through SQLiteOpenHelper. If the database does not appear in Chrome DevTools — check that getWritableDatabase() has been called at least once in the application code.
Stetho must be the last interceptor in the OkHttp chain to see modified requests. The correct order: AuthInterceptor first, then LoggingInterceptor, then StethoInterceptor last.
Stetho is effective for checking the correctness of JSON serialization before sending to the server. Open the Network Inspector, find the request and view the request body in Raw mode to make sure the field structure and data types are correct.
Stetho displays all databases created through SQLiteOpenHelper. If the database does not appear in Chrome DevTools — check that the getWritableDatabase() method has been called at least once in the application code. For migrations, run ALTER TABLE through the SQL console and verify the result with a SELECT query.
Stetho must be the last interceptor in the OkHttp chain to display the final modified requests. The correct sequence: AuthInterceptor first, then LoggingInterceptor, then StethoInterceptor last for correct logging.
Frequently asked questions
Connect the device via USB, run adb forward tcp:8080 localabstract:stetho_default and open the chrome://inspect page in Chrome. Make sure Stetho is initialized in the application code and the device is detected in the Remote Target list.
Yes, Stetho works on Android 12+, but requires an explicit INTERNET permission in the manifest. On Android 14+ an ADB update may be required. For new projects Google recommends Android Studio Inspector, but Stetho remains functional on all versions.
Yes, SQLite Inspector, SharedPreferences and View Hierarchy work without OkHttp. Network Inspector requires integration with OkHttp or HttpURLConnection through the stetho-okhttp3 or stetho-urlconnection modules. The base Stetho core does not depend on a network library.
Use debugImplementation in Gradle: debugImplementation 'com.facebook.stetho:stetho:1.6.0'. In a release build the Stetho code is not compiled. If initialization is extracted into a separate class — wrap the call with a BuildConfig.DEBUG check.
The main alternatives: Chucker (HTTP inspection in the app, with UI), Android Studio Profiler and Network Inspector tools, as well as Flipper (a modular platform from Facebook with extended functionality). Chucker is especially popular as an in-app solution without Chrome DevTools.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also