stetho android how to use
- User
stetho android how to use
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
stetho android how to use
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here’s a quick guide to get you up and running with Facebook’s Stetho in your Android app. Stetho lets you inspect network calls, databases, shared-prefs, view hierarchy, and more—directly from Chrome DevTools!
In your app-module build.gradle:
dependencies {
// Core Stetho
implementation 'com.facebook.stetho:stetho:1.6.0'
// (Optional) If you use OkHttp for networking:
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
}
⚠️ Always check for the latest version on Maven Central.
Create (or open) your Application subclass and initialize Stetho in onCreate():
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(
Stetho.defaultDumperPluginsProvider(this)
)
.enableWebKitInspector(
Stetho.defaultInspectorModulesProvider(this)
)
.build()
);
}
}
Don’t forget to register it in the AndroidManifest.xml:
<application
android:name=".MyApp"
… >
…
</application>
If you’re using OkHttp 3.x/4.x:
OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor(new StethoInterceptor())
.build();
This lets you see all HTTP(s) traffic under the Network tab.
chrome://inspectYou’ll see a DevTools window with:
| Tab | What it shows |
|---|---|
| Elements | Your app’s view hierarchy (layout inspector) |
| Network | All HTTP/S requests & responses |
| Resources | SQLite databases, SharedPreferences, files, etc. |
| Console | console.log() output from Stetho Runtime |
| Profiles | CPU / memory profiles (via dumpapp) |
Custom Inspector Modules
You can provide your own InspectorModulesProvider to add custom data (e.g., internal caches).
Stetho with ProGuard
No special rules needed; Stetho is only active in debug builds.
dumpapp CLI
In your terminal run:
adb shell run-as com.your.package.name \
/data/data/com.your.package.name/app_webview/..\lib/libstetho.so \
dumpapp --help
to see available dumper plugins.
🎉 That’s it! You now have a powerful in-browser debug console for your Android app.
Got questions or hit a snag? Let me know!