Debugging and Logging in Android

Google+ Pinterest LinkedIn Tumblr


At the time of development, we always faced errors, exceptions, and crashes and tracked by Android Logging system. But it will be a nightmare to find a bug in production which occurs on the user’s device. ‘Fabric’s Crashlytics’ provide a solution for that. Crashes and exceptions can be logged with them from remote devices.

Most Useful Tools for logging & debugging

  1. Bugfender
  2. Android Debug Database
  3. Fabric Crashlytics (Firebase) & Answer
  4. Stetho
  5. Timber
Major things missing in android app development
  • Not able to check & view shared preference variables
  • For logging (standard logging) always need to give tags.
  • Remotely view logs for all devices.
  • Database access is very difficult.
  • Inspect elements.

1. Bugfender

The remote logging system for iOS and Android application.

Why Bugfender? At the time of development

  • Logs from many devices required.
  • Not possible to attach all the devices with the development machine.
  • Need to check some special values on some events fire.
  • The log will be saved on cloud and log file can be downloaded as well.
  • Logged all remote devices logs.
  • Logs saved on the cloud also.
  • The free version provides last 24 hours logs.
  • Shows different logs for different devices.
  • One can enable/disable devices as well as logging on those devices.
  • Have different methods to print UI logs, all events logs(complete Android system logs).
  • The developer can log only particular event logs.

Read more for Bugfender Integration

2. Fabric Crashlytics (Firebase) & Answer

  • Able to log errors and exception an complete stack trace for remote devices
  • Can log for ‘debug’ as well as for ‘production’.
  • Also, provide details of device models.
  • All the crashes and exceptions will be notified via email, every time they occur.
  • Crashes reported automatically.
  • To log caught exceptions crashlytics.logException(exception);
  • We can also provide some key-value pair for more reference of exception.
  • Sometimes didn’t get complete context of a class where an error occurs.
  • Android logs for crashes are sometimes difficult to understand.

3. Stetho

Stetho is mainly a debugging tool for Android application by Facebook. It uses Chrome’s Developer tool to display debugging data of application.

Features provided:
  • View Hierarchy
  • Database inspection
  • Shared Preferences
  • JavaScript Console
  • Dumpapp

2.1 View Hierarchy: Able to view all the View elements and detailed properties (styles). The user will have a complete hierarchy view of layout including layouts which were integrated at runtime.

2.2 DataBase Inspection: User can view complete database tables and also able to do the query for some specific data and also alter the data directly from here.

2.3 Shared Preferences: User can view all the shared preferences variables and also changes these values.

2.4 Network Inspection: User can view all the network request and JSON response, image preview of application.

2.5 JavaScript Console: User can interact with the application and even Android SDK by executing javascript code in the console.

2.6 Dumpapp: Provided command line interface for the Android application.

Integration: Follow the below link

When user run the code than He will see request and response in ‘Network’ tab of Developers tool.

Inspection Process Once a user is done with the integration process

  • Open chrome browser in the developer system.
  • Navigate to ‘chrome://inspect’.
  • Here user will find all the connected devices with the Application name.
  • Click ‘inspect’ to start the inspection.

4. Timber’s Requirement:

  • Do not require to specify ‘TAG’ for class context like ‘Android log system. Its timber’s inbuilt feature.
  • Can control which kind of logs want to show in crashlytics. For Example errors and exceptions. It will not show ‘info’ and ‘warnings’ log in crashlytics
  • We can print line-number as well with the logs.
  • Provide all logging methods, provided by ‘Android logging system’. Like, debug, info, error, wtf etc


//gradle dependency 
implementation 'com.facebook.stetho:stetho-timber:1.4.2'
  • In Application, class add below code
Timber.plant(new StethoTree()); 

Now timber provides all kind of logging eg. debug, info, verbose etc in ‘Developer tool’s console’. Do not need to add ‘TAG’, just add messages where ever it is required.

  • Do not work for remote devices.
  • Logging can’t be saved.

5. Android Debug Database

Allows you to view databases & shared preferences in your development machine browser.

  • View database.
  • Run sql query to modify or delete data from DB.
  • View/edit/delete shared preferences of application.
  • Directly edit the database values.
  • Search and sort data.
  • Download database.
  • Development machine & device should be in the same network.

Integration: Follow the link


Leave a Reply

3 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
2 Comment authors
RahulMVP Architect Android apps with Dagger2, Retrofit & RxJava2 - AndroidWaveRahul Recent comment authors
newest oldest most voted
Notify of

Good, content but I expect more explanation about each one


Good, content but I expect more explanation about each one