Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.

Related tags

Spring Boot stetho
Overview

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:

implementation 'com.facebook.stetho:stetho:1.6.0'

or Maven:

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

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

implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'

or:

implementation 'com.facebook.stetho:stetho-urlconnection:1.6.0'

You can also enable a JavaScript console with:

implementation 'com.facebook.stetho:stetho-js-rhino:1.6.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 MIT-licensed. See LICENSE file for more details.

Comments
  • Screencasting support

    Screencasting support

    Tries to implement screencasting support as described in #189 It is still a bit janky but works. I'll try to get it improved.

    screen shot 2015-05-14 at 11 44 36 pm

    Still needs to be fixed:

    • When the app is closed while the screencast is running, we get a crash since the bitmap is disposed and we never got a chance to set mIsRunning to false. Need to find a way to detect that the activity is closing, maybe isFinishing() would do.
    • Jankiness

    Nice to have:

    • Touch support
    CLA Signed 
    opened by felipecsl 45
  • Chrome doesn't see my device

    Chrome doesn't see my device

    Hi, I followed all the steps for setting up Stetho. But my Chrome just flashes

    Pending authentication: please accept debugging session on the device.

    Please advise.

    opened by IgorGanapolsky 41
  • Chrome only shows a white screen

    Chrome only shows a white screen

    Trying to inspect using Chrome only shows a white screen. This is Chrome 54.0.2840.98 (64-bit) on OSX 10.11.6

    screen shot 2016-11-30 at 8 09 30 pm

    Looking at logcat I can see that stetho was initialized and that is supposed to be listening.

    com.facebook.stetho.sample I/SampleDebugApplication: Stetho initialized in 5 ms
    com.facebook.stetho.sample I/stetho: Listening on @stetho_com.facebook.stetho.sample_devtools_remote
    

    Any tips on debugging this issue?

    opened by carlospaulino 27
  • OkHttp3 Interceptor crash

    OkHttp3 Interceptor crash

    I just upgraded OkHttp to version 3.0.1 and Stetho to version 1.3.0 (and its corresponding new OkHttp3 network interceptor).

    I'm experiencing the following NullPointerException when inspecting HTTP traffic:

    E/stetho: com.facebook.stetho.inspector.elements.android.DialogFragmentDescriptor.getChildren() emitted a null child at position 0 for element LayoutFragment{3a8b2dd3 #0 id=0x7f0c00dc}
    E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
             Process: com.artech.androidbasictest.testgxsalto, PID: 29855
             java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
             at com.facebook.stetho.okhttp3.StethoInterceptor$OkHttpInspectorResponse.connectionId(StethoInterceptor.java:229)
             at com.facebook.stetho.inspector.network.NetworkEventReporterImpl.responseHeadersReceived(NetworkEventReporterImpl.java:143)
             at com.facebook.stetho.okhttp3.StethoInterceptor.intercept(StethoInterceptor.java:73)
             at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
             at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
             at okhttp3.RealCall.getResponse(RealCall.java:241)
             at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
             at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
             at okhttp3.RealCall.access$100(RealCall.java:30)
             at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
             at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:33)
             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
             at java.lang.Thread.run(Thread.java:818)
    
    opened by juandiana 27
  • Can't get it to work on main application

    Can't get it to work on main application

    Hi,

    Thanks for this librarie that opens new perspectives. I can make the sample application work perfectly but can't make my main application.

    I can inspect the application, but instead of seeing the

     Welcome to Stetho
              Attached to com.facebook.stetho.sample
    

    I see in red

    Not implemented: Profiler.setSamplingInterval
    

    And nothing available in the resources tab.

    On the application logcat I have the exact same things as the sample application :

    D/ChromeDevtoolsServer﹕ onOpen
    

    Then

    D/ChromeDevtoolsServer﹕ Method not implemented: Not implemented: Page.canEmulate 
    

    and some others.

    Then finally the

    D/ChromeDevtoolsServer﹕ onClose: reason=1011 EOF while reading 
    

    when I close the inspect window.

    No error or nothing so hard to understand the problem.

    opened by Tolriq 25
  • Support target SDK version of android-MNC for android m release

    Support target SDK version of android-MNC for android m release

    What's the timeline for an Android M compatible release?

    Apache HTTP client is going away and I see various classes (DumpappHandler.java, ChromeDiscoveryHandler.java, etc.) using it.

    enhancement 
    opened by gpolak 22
  • NullPointerException

    NullPointerException

    I'm can't reproduce it every time (version 1.3.1)

    Process: com.adoriasoft.quietping, PID: 9303
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null
    at com.facebook.stetho.inspector.elements.Document$4.store(Document.java:388)
    at com.facebook.stetho.inspector.elements.ShadowDocument$Update.getChangedElements(ShadowDocument.java:297)
    at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:372)
    at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:327)
    at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:30)
    at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:682)
    at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:67)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5951)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
    
    bug 
    opened by droidandrew 18
  • Memory leak in Stetho 1.2.0

    Memory leak in Stetho 1.2.0

    We've experienced a severe memory leak after we integrated Stetho into our app. Through bisection we could pin down the exact revision when we did this and could verify that - once Stetho was removed - the memory leak was gone.

    The leak showed up in Android's Memory Monitor, where constantly around 20KB/s have been added on top until the limit was reached and GC kicked in. Then, from the lower level onwards, memory consumption raised again.

    The way we integrated Stetho was fairly basic, we only enabled it in our custom Application instance via Stetho.initializeWithDefaults(this) for DEBUG builds.

    enhancement 
    opened by realdadfish 18
  • Implements support for DOM.setAttributesAsText()

    Implements support for DOM.setAttributesAsText()

    Fixes #145

    This is my initial stab at implementing a new DOM request setAttributesAsText().

    Right now this correctly calls any setter that has a single argument of type int, float, boolean, String or CharSequence of View (and subclasses) using the MethodInvoker. Examples are setTex()t, setId(), setAlpha(), etc. More types can be supported by extending TypedMethodInvoker.

    Question:

    • Do we need to send a response back after completed?
    CLA Signed 
    opened by felipecsl 18
  • Fix importClass and importPackage not finding external classes

    Fix importClass and importPackage not finding external classes

    For external packages, the package name needs to be prefixed with Packages. per https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java#External_Packages_and_Classes

    Mostly fixes #405

    CLA Signed 
    opened by paour 17
  • Incompatibility with Java 8

    Incompatibility with Java 8

    Hi, when I try to integrate your library, my Android Studio throws Java 8 compile errors. As a result, I cannot use Stetho if my IDE/project is setup to use Java 8.

    Please advise.

    opened by IgorGanapolsky 17
  • Inspect Devices UI is distorted

    Inspect Devices UI is distorted

    Everything was working fine until chrome version - 86.0.4240.75 (Official Build) (x86_64). Attached are the screenshots below.

    Screenshot 2022-09-17 at 3 20 33 AM Screenshot 2022-09-17 at 3 20 15 AM

    On the latest version of the Google Chromes Version 105.0.5195.125 (Official Build) (x86_64)

    The network section moved to the complete right side and we can't see anything or we can't drag too. Screenshot 2022-09-17 at 3 23 52 AM

    opened by pradeepkommu 2
  • exempt a disk read from StrictMode as stetho is strictly a debug orie…

    exempt a disk read from StrictMode as stetho is strictly a debug orie…

    Violation:

    StrictMode policy violation; ~duration=5 ms: android.os.strictmode.DiskReadViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1596)
        at libcore.io.BlockGuardOs.fstat(BlockGuardOs.java:174)
        at libcore.io.ForwardingOs.fstat(ForwardingOs.java:106)
        at libcore.io.IoBridge.open(IoBridge.java:481)
        at java.io.FileInputStream.<init>(FileInputStream.java:160)
        at java.io.FileInputStream.<init>(FileInputStream.java:115)
        at com.facebook.stetho.common.ProcessUtil.readProcessName(ProcessUtil.java:49)
        at com.facebook.stetho.common.ProcessUtil.getProcessName(ProcessUtil.java:38)
        at com.facebook.stetho.server.AddressNameHelper.createCustomAddress(AddressNameHelper.java:20)
        at com.facebook.stetho.Stetho$Initializer.start(Stetho.java:449)
        at com.facebook.stetho.Stetho.initialize(Stetho.java:134)
    

    But "/proc/self/cmdline is a memory file and won't actually hit disk" thus it can be exempted.

    CLA Signed 
    opened by jijichen 0
  • Usage of weak crypto algorithms like SHA-1 in Stetho

    Usage of weak crypto algorithms like SHA-1 in Stetho

    Summary

    Our Penetration testing team has identified usage of weak crypto algorithms like SHA-1 in Stetho and logged security vulnerability. What are the plans to migrate to the latest crypto algorithms? Can you please migrate to the latest crypto algorithms to mitigate this?

    Recommendation: Utilize cryptographic hashing algorithms that are considered secure and advocated for in best practice recommendations. Guidance can be found for Android For more guidance on best practices in picking strong cryptography, please see OWASP's Cryptographic Storage Cheat Sheet.

    Motivations

    Security Vulnerability.

    opened by nidhi88 1
  • NoSuchMethodError issue

    NoSuchMethodError issue

    crash occurs on 1 user (from 1.29M active user) with device Samsung Galaxy A3(2016).

    Here is crashlytics log

    Fatal Exception: java.lang.NoSuchMethodError: No interface method nextRequestId()Ljava/lang/String; in class Lcom/facebook/stetho/inspector/network/NetworkEventReporter; or its super classes (declaration of 'com.facebook.stetho.inspector.network.NetworkEventReporter' appears in base.apk:classes2.dex) at com.facebook.stetho.okhttp3.StethoInterceptor.intercept(StethoInterceptor.java:40)

    can anyone tell me to fix the issue?

    opened by edtslib 0
  • Stetho doesn't capture network in network inspector

    Stetho doesn't capture network in network inspector

    description

    i'm using stetho for inspect network for release mode apk. but chrome devtool Netowrk tab doen't show anything.

    environment

    Chrome version: 88.0.4324.0(developer build) (x86_64) RN version: 0.53.2 stetho versino: 1.6.0 stetho-okhttp3: 1.6.0

    opened by Einere 2
Releases(v1.6.0)
Owner
Meta
We are working to build community through open source technology. NB: members must have two-factor auth.
Meta
A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio

Rongcloud-uniapp-sdk-demo A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio 这是一个为了给uniapp在Android平台打出debug-apk的demo

Zongkui Guo 1 Oct 13, 2021
Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Gabriele Rizzo 865 Jan 2, 2023
Literally just adds milk, to act as a bridge for any other mods that want to do the same.

Milk lib Literally just adds milk, to act as a bridge for any other mods that want to do the same. See the Milk class for customisation; It allows for

null 5 Oct 17, 2022
Velocity global chat/discord bridge

VelocityDiscord Velocity global chat/discord bridge Default config generated on startup: # Don't change this config_version="1" [discord] # Bot token

Foo 8 Dec 18, 2022
Simple Design for Java bridge with Javascript. Also can get javascript console.log.

SDBridgeKotlin is here. If your h5 partner confused about how to deal with iOS and Android. This Demo maybe help. 最常见的问题. WebViewJavascriptBridge is n

null 25 Dec 18, 2022
I had too much coffee and decided to mirror my actions by writing too many programs in Java.

Raging Coffee Table of Contents Description Running the Programs Extra Dependencies Roadmap Further Reading Known Issues Resources Contributions Descr

Thoroughfare by the Brooks 20 Dec 15, 2022
this repo is probs gonna die cuz idk very much java but i will update it when i learn how to actually DO SHIT

pastegod.cc shitty rename of zihasz client base rn but as i learn java i will paste-i mean add modules ;) (23/9/2021) why is everyone starring and wat

null 9 Dec 9, 2022
I learned so much in this project, a twitch+ recommendation system

VisualHunter I learned so much in this project, a twitch+ recommendation system, a Personalized Twitch Resources Recommendation ● Built a full-stack w

Rui Zhang 2 Jan 12, 2022
Allows changing of hurt animation modifier, changing how much the user's camera moves after the player being hurt.

Hurt Animation Modifier Allows changing of hurt animation modifier, changing how much the user's camera moves after the player being hurt. Credit to W

null 5 May 17, 2022
Java-Programs---For-Practice is one of the Java Programming Practice Series By Shaikh Minhaj ( minhaj-313 ). This Series will help you to level up your Programming Skills. This Java Programs are very much helpful for Beginners.

Java-Programs---For-Practice is one of the Java Programming Practice Series By Shaikh Minhaj ( minhaj-313 ). This Series will help you to level up your Programming Skills. This Java Programs are very much helpful for Beginners. If You Have any doubt or query you can ask me here or you can also ask me on My LinkedIn Profile

Shaikh Minhaj 3 Nov 8, 2022
InterfaceMaker is a modern plugin to handle and customize join items, hotbars and menus with a developer and administrator friendly API.

Interface Maker InterfaceMaker is a modern plugin to handle and customize join items, hotbars and menus with a developer friendly API. Features Simple

2LStudios - Minecraft 10 Nov 27, 2022
Powerful and flexible library for loading, caching and displaying images on Android.

Universal Image Loader The great ancestor of modern image-loading libraries :) UIL aims to provide a powerful, flexible and highly customizable instru

Sergey Tarasevich 16.8k Jan 2, 2023
A powerful image downloading and caching library for Android

Picasso A powerful image downloading and caching library for Android For more information please see the website Download Download the latest AAR from

Square 18.4k Dec 31, 2022
An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

GFX-AdPromote An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & nat

SAID MOTYA 10 Dec 25, 2022
Ethylene is a open-source, lightweight, general-purpose compatibility layer standing between the developer and the chaotic world of configuration file formats.

Ethylene Ethylene is a open-source, lightweight, general-purpose compatibility layer standing between the developer and the chaotic world of configura

Steank 7 Aug 9, 2022
This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs

About this Repository This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs It contains the following folders:

Rasha Omran 1 Jan 28, 2022
a program to periodically synchronize the tanzu developer portal profile page with my latest-and-greatest

Tanzu Developer Center Feed Processor 2.0 This is meant to be a logical successor to the original feeds processor. The program pulls in data from the

Developer Advocacy 5 Jul 9, 2022
Software developer training camp

Java-Camp Software developer training camp 1. Java Temelleri - 1 2. Java Temelleri - 2 3. Java Nesne Yönelimli Programlamaya Giriş 4. Java Nesne Yönel

Yüksel Can Özdemir 8 Dec 19, 2022
A developer oriented, headless ecommerce framework based on Spring + GraphQL + Angular.

GeekStore A developer oriented, headless ecommerce framework based on Spring + GraphQL + Angular. Headless means GeekStore only focus on the backend,

波波微课 13 Jul 27, 2022