Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
Java JavaScript Other
Clone or download
Latest commit 22ea395 Feb 22, 2018
aadsm and longinoa Fix the way /proc/net/unix is being parsed (#589)
dumpapp stopped working for me because /proc/net/unix has two spaces to separate state from inode when the inode length is less than the maximum inode length (123 vs 1234).

E.g.:

```
00000000: 00000002 00000000 00010000 0001 01 76292 /dev/socket/cryptd
00000000: 00000002 00000000 00010000 0001 01  3836 @stetho_com.facebook.wakizashi_devtools_remote
```

We should be parsing this with `\s+` and not a simple space since the output date is a table that is formatted to look like columns in the print out.
Permalink
Failed to load latest commit information.
.idea Android Studio 2.2 preview 2 random scribbles Jun 1, 2016
build-tools Expand scraper.js support for events. Mar 15, 2017
docs/images Initial commit Jan 29, 2015
gradle/wrapper Update Gradle wrapper to 4.1 Aug 8, 2017
scripts Fix the way /proc/net/unix is being parsed (#589) Feb 22, 2018
stetho-js-rhino Merge pull request #543 from schrnz/patch-1 Dec 29, 2017
stetho-okhttp Fix build break and test break Dec 28, 2017
stetho-okhttp3 Fix build break and test break Dec 28, 2017
stetho-sample Merge pull request #515 from jasta/sockets Apr 13, 2017
stetho-timber Update build tools to 25.0.2 Mar 14, 2017
stetho-urlconnection Update build tools to 25.0.2 Mar 14, 2017
stetho Merge pull request #585 from jasta/fatjar-exclude-R Dec 29, 2017
.gitignore Initial commit Jan 29, 2015
.travis.yml Update build tools to 25.0.2 Mar 14, 2017
CHANGELOG.md Update CHANGELOG.md to v1.5.0 Apr 13, 2017
CONTRIBUTING.md Update CONTRIBUTING.md Apr 16, 2015
LICENSE Initial commit Jan 29, 2015
PATENTS Update patent grant Apr 14, 2015
README.md Fix issue #480 : Documentation to add MyApplication to AndroidManifes… Aug 14, 2017
build.gradle Update Android Gradle plugin to 2.3.3 Aug 8, 2017
gradle.properties Update to 1.5.1-SNAPSHOT Apr 13, 2017
gradlew Update Gradle wrapper to 4.1 Aug 8, 2017
gradlew.bat Update Gradle wrapper to 3.4.1 Mar 14, 2017
release.gradle Rename helper methods for mvn repo Mar 14, 2017
settings.gradle Add OkHttp 3 integration, Deprecate OkHttp 2 integration. Jan 18, 2016

README.md

Stetho Build Status

Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature natively part of the Chrome desktop browser. Developers can also choose to enable the optional dumpapp tool which offers a powerful command-line interface to application internals.

Once you complete the set-up instructions below, just start your app and point your laptop browser to chrome://inspect. Click the "Inspect" button to begin.

Set-up

Download

Download the latest JARs or grab via Gradle:

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

or Maven:

<dependency>
  <groupId>com.facebook.stetho</groupId>
  <artifactId>stetho</artifactId>
  <version>1.5.0</version>
</dependency>

Only the main stetho dependency is strictly required; however, you may also wish to use one of the network helpers:

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

or:

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

You can also enable a JavaScript console with:

compile 'com.facebook.stetho:stetho-js-rhino:1.5.0'

For more details on how to customize the JavaScript runtime see stetho-js-rhino.

Putting it together

Integrating with Stetho is intended to be seamless and straightforward for most existing Android applications. There is a simple initialization step which occurs in your Application class:

public class MyApplication extends Application {
  public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
  }
}

Also ensure that your MyApplication Java class is registered in your AndroidManifest.xml file, otherwise you will not see an "Inspect" button in chrome://inspect/#devices :

<manifest
        xmlns:android="http://schemas.android.com/apk/res/android"
        ...>
        <application
                android:name="MyApplication"
                ...>
         </application>
</manifest>                

This brings up most of the default configuration but does not enable some additional hooks (most notably, network inspection). See below for specific details on individual subsystems.

Enable network inspection

If you are using the popular OkHttp library at the 3.x release, you can use the Interceptors system to automatically hook into your existing stack. This is currently the simplest and most straightforward way to enable network inspection:

new OkHttpClient.Builder()
    .addNetworkInterceptor(new StethoInterceptor())
    .build()

Note that okhttp 2.x will work as well, but with slightly different syntax and you must use the stetho-okhttp artifact (not stetho-okhttp3).

As interceptors can modify the request and response, add the Stetho interceptor after all others to get an accurate view of the network traffic.

If you are using HttpURLConnection, you can use StethoURLConnectionManager to assist with integration though you should be aware that there are some caveats with this approach. In particular, you must explicitly add Accept-Encoding: gzip to the request headers and manually handle compressed responses in order for Stetho to report compressed payload sizes.

See the stetho-sample project for more details.

Going further

Custom dumpapp plugins

Custom plugins are the preferred means of extending the dumpapp system and can be added easily during configuration. Simply replace your configuration step as such:

Stetho.initialize(Stetho.newInitializerBuilder(context)
    .enableDumpapp(new DumperPluginsProvider() {
      @Override
      public Iterable<DumperPlugin> get() {
        return new Stetho.DefaultDumperPluginsBuilder(context)
            .provide(new MyDumperPlugin())
            .finish();
      }
    })
    .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
    .build())

See the stetho-sample project for more details.

Improve Stetho!

See the CONTRIBUTING.md file for how to help out.

License

Stetho is BSD-licensed. We also provide an additional patent grant.