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

This is an archived page. It's not actively maintained.

This tutorial assumes that you have:

  • Fennec or Firefox for Android 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 (like a crash, error or odd behaviour) is happening. Viewing logs is often the best way to diagnose a problem, and is a good point of reference for developers.

This article will explain how to download and set up an environment to gain access to  Android system logs. The Android operating system automatically creates, and maintains a activity log, an audit trail of events, messages and actions performed that can be used to understand the diagnose system activity. The Android Software Development Kit provides a great way to view this 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 lets 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

Logcat of a Fennec Crash
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.

Original document information

Shortened Forum Response Version

Already in the support forum notation for you :-)


Ok so I tried this finally and got it to work: this might be long but a shortened version:

# . Connect the device to the computer via usb.

# 2. In android settings go to About device and double tap on build id 7 times

# 3. Go back and now see the developer menu

# 4. Open and enable remote debugging

# 5. Open up Firefox on the android go to settings > developer tools and check remote debugging

# 6. From Desktop go to Tools > Connect

# 7. Open Tools > Console

# 8. Click on gear and on the far right click on "Remote debugging for this session only"

# 9. [adb sdk install required] in a terminal window adb devices make sure a device is listed.

# 10.  On desktop in the window that opened up when you opened up connect click on connect

# 11. Immediately after run this in the terminal:

adb forward tcp:6000 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket

t# 12. On the device hit enable on the connection

# 13. should be connected on the connect and click on the remote tabs.

# 14 the logs will start to show up in the console.

# 15. If you need adb log cat logs run in the terminal before you start to test:

adb logcat > text.txt

# do your thing, and attach it to a bug.


Additional Resources

  • Author(s): Aaron Train
  • Date last modified: February 18, 2011 at 3:17 pm PST