Android Debugging Made Easy

At Haptik, one of the world’s largest conversational AI platforms, we build new features for our mobile app and SDKs almost on a daily basis. As the application development process started becoming more complex & tedious, so did the process of debugging.

 

We found it difficult to debug things around the network layer communication of the application, databases and view hierarchies using just Android Studio.

 

Here’s are the specific problems we were facing:

 

  1. 1. As we kept adding newer modules/features in our app on regular basis we found it really difficult to debug those issues in real time
  2. 2. The libraries we were using did not have in-depth logging around errors
  3. 3. There were not many good options out there to understand application behavior in depth
  4.  

This is when we started our hunt for a library that could help us debug in a much better way. And lo! We came across a new library open sourced by Facebook called Stetho.

 

In this blog post, we’re going to explain what Stetho does and why it’s such an essential tool for Haptik.

 

Process-of-Debugging-Feature-Image

 

What is Stetho?

 

Stetho is one of the most famous Android debugging libraries written by Facebook. What makes it stand out from other debug libraries is its deep and powerful integration with Chrome Developer Tools(DevTools for short). With it, developers have much more convenient and richer access to their app’s data.

 

Just like we debug and inspect our web pages using Chrome DevTools, developers can now inspect their app’s data and perform operations on it using Stetho. So, if you are saving user data in an SQLite table or in shared preferences, you can use Stetho to check if data is being saved properly or to see how your app behaves with different sets of data.

 

In simple words, you can perform all CRUD operations using Stetho GUI. Developers can also choose to enable the optional dumpapp tool which offers a powerful command-line interface to application internals.

 

stetho

 

How Do I Integrate Stetho in an Application?

 

In this section of the blog, I will tell you how to get started with Stetho and get it up and running on your local machine.

 

Prerequisites

 

Before we can get started, you need some tools to utilize Stetho. You’ll need to install the following:

 

1) Chrome Browser with DevTools for debugging.

2) Android ADB is already pre-installed if you’re using Android Studio. If not, you’ll need to install it.

 

Dependencies

 

Add Stetho dependencies to your build.gradle file: