Docs > Mobile Firefox > Fennec on Android: Logging with the Android Debug Bridge and Logcat

Fennec on Android: Logging with the Android Debug Bridge and Logcat

This tutorial assumes that you have:

  • Fennec or Firefox Mobile on your device
  • A USB data cable connected from your device to your personal computer
  • Enabled USB Debugging on your device in: Settings → Applications → Development

Often times it is useful and necessary to determine what is going on during the execution of a program, in order to understand why something, albeit a crash, an error or odd behaviour is happening. Viewing logs is often the best way to diagnose a problem, and is perfect point of reference for developers to analyze and interpret to further acknowledge a potential or existing issue with an application or service. Gaining access to and or seeking system logs is not always a feasible task by trivial means. This article will provide a walkthrough in downloading and setting up an environment to which one can gain access to and view Android system logs and provide the necessary details to get one started.

The Android operating system automatically creates, and maintains a log of activity, an audit trail of events, messages and actions performed that can be used to understand the activity of the system to identify, correlate and ultimately diagnose. The Android Software Development Kit provides a great way to go about viewing this information and data.

The Android Software Development Kit includes a variety of tools, sample code, and docs one would need to develop and build mobile applications for the Android platform. The SDK contains the tools we need to get started. The Android Debug Bridge tool is a command line tool that will let us gain access to the device we are using.

Let us take a look at the Android Software Development Kit, and the Android Debug Bridge tool and a second tool named logcat, that can be used to view the internal log of the Android system.

Step 1. Preparing Your Computer – Installing and setting up the Android Software Development Kit

Documentation on the Android Developers website contains information on downloading the correct package for your platform and installing the Android Software Development Kit. Upon starting the Android SDK and AVD Manager, you will need to install the Android SDK Platform-tools. This variety of platform tools contain essentials that are used to develop and debug your application. This package also provides us with the essential tools we need in get started, it is the first starting point in our walkthrough. Downloading and installing the Android SDK Platform-tools can be read in detail here. In the screenshot below, I started the AVD manager by running the command-line tool: android which is under the tools directory in the extracted Android SDK folder.

Android SDK and AVD Manager

Android SDK and AVD Manager

Step 2. Everything Installed and Setup – Starting up the Android Debug Bridge

Upon completion of installing and setting up the Android Software Development Kit and installing the Android SDK Platform-tools through the Android SDK and AVD Manager, the Android Debug Bridge tool can be started by performing the following steps, with an additional pre-step:

Pre-step: Connect your Android operated device to your computer via a USB connection cable

  1. Open a terminal or command prompt on your operating system
  2. Navigate to the extracted Android SDK folder on your hard disk
  3. Navigate to the sub directory named: platform-tools
  4. Run the command line tool: adb logcat

Note: You can verify that your device is connected by executing adb devices from your SDK platform-tools/ directory. If connected, you’ll see the device name listed as a “device.”This command will determine if your device is successfully communicating with the Android Debug Bridge and will output a serial number identifying your Android operated device.

Android Debug Bridge - Logcat

Android Debug Bridge - Logcat

Note: Viewing messages fly by through logcat can be pretty scary! A tip I like to use is by filtering output through the grep utility, for example: adb logcat | grep fennec

Example: Fennec crash output

Android Debug Bridge - Example Logcat messages of a Fennec Crash

Android Debug Bridge - Example Logcat messages of a Fennec Crash

In the example screenshot above, one can see an important messages in the system log related to a recently occurred Fennec crash. The best course of action from here is to take this output and copy it over to an associated bug filed on Bugzilla under the Fennec product by clicking here. The developers would greatly appreciate it!

Disclaimer Note: Log data may contain personal information. I would advise one to look through ones log first and remove anything personal or anything non pertinent.

Additional Resources