Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/facebook/stetho
Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
https://github.com/facebook/stetho
Last synced: 3 days ago
JSON representation
Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
- Host: GitHub
- URL: https://github.com/facebook/stetho
- Owner: facebook
- License: mit
- Created: 2015-01-22T22:34:10.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2024-10-26T03:44:45.000Z (about 2 months ago)
- Last Synced: 2024-11-28T20:57:37.041Z (14 days ago)
- Language: Java
- Homepage: http://facebook.github.io/stetho/
- Size: 2.28 MB
- Stars: 12,675
- Watchers: 375
- Forks: 1,128
- Open Issues: 82
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome - stetho - Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more. (Java)
- awesome-list - Stetho - A debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more. (Mobile Development / C++/C Toolkit)
- awesome-chrome-devtools - Facebook Stetho - Native Android debugging with Chrome DevTools. (Using DevTools frontend with other platforms / Browser Adapters)
- awesome-hacking-lists - facebook/stetho - Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more. (Java)
README
# Stetho [![Build Status](https://travis-ci.org/facebook/stetho.svg?branch=master)](https://travis-ci.org/facebook/stetho)
[Stetho](https://facebook.github.io/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](https://github.com/facebook/stetho/releases/latest) or grab via Gradle:
```groovy
implementation 'com.facebook.stetho:stetho:1.6.0'
```
or Maven:
```xmlcom.facebook.stetho
stetho
1.6.0```
Only the main `stetho` dependency is strictly required; however, you may also wish to use one of the network helpers:
```groovy
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
```
or:
```groovy
implementation 'com.facebook.stetho:stetho-urlconnection:1.6.0'
```You can also enable a JavaScript console with:
```groovy
implementation 'com.facebook.stetho:stetho-js-rhino:1.6.0'
```
For more details on how to customize the JavaScript runtime see [stetho-js-rhino](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:```java
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` :```xml
```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](https://github.com/square/okhttp)
library at the 3.x release, you can use the
[Interceptors](https://github.com/square/okhttp/wiki/Interceptors) system to
automatically hook into your existing stack. This is currently the simplest
and most straightforward way to enable network inspection:```java
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](stetho-sample) 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:```java
Stetho.initialize(Stetho.newInitializerBuilder(context)
.enableDumpapp(new DumperPluginsProvider() {
@Override
public Iterable get() {
return new Stetho.DefaultDumperPluginsBuilder(context)
.provide(new MyDumperPlugin())
.finish();
}
})
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
.build())
```See the [`stetho-sample` project](stetho-sample) for more details.
## Improve Stetho!
See the [CONTRIBUTING.md](CONTRIBUTING.md) file for how to help out.## License
Stetho is MIT-licensed. See LICENSE file for more details.