Features of Stetho
- Stetho is an open-source debugging platform.
- It provides a rich and highly interactive experience.
- With the help of Stetho native applications debugging very simple.
- It offers you to use Google Chrome debugging tool for various activities.
- It provides hierarchy inspection during debugging.
- Also, Stetho allows network, database management, and more interacting features.
- Stetho uses HTTP web-socket to send data.
The problem with debugging network traffic while developing android applications, debugger facing problems with traditional debugging tools get messed up and inspection got very complex while switching the devices.
The Solution Provided by Stetho
The debugging is more reliable and easy with the Stetho library because it uses the chrome debugging tool which is supports web-socket and using it for network debugging. Stetho automated the call inspection, so it becomes more important for android developers.
How to Work with Chrome Dev Tool?
Stetho uses an HTTP web Socket server that sends all debugging information to the browser. It is accessible through:
Step by Step Implementation
Step 1: Add the following dependency in the build.gradle file.
Step 2: Register your class in AndroidManifest.xml, and initialize it in the application.
Initialize your library with a single line of code (for example ):
Updating your manifest file in your android project:
Step 3: Enable network inspection.
Following method is the easiest and simpler w2ay to enable network inspection when you constructing the okHttpClient instance:
How to check?
Start emulator on the device. Then open chrome://inspect on Chrome and your emulator device should appear, after that click inspects to launch a new window and click the network tab to watch network traffics.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.