Friday, January 14, 2011

Alternative logcat viewer

If you are developing Android with Eclipse and have several devices and emulators connected you may have been annoyed by the constant disconnection that the DDMS view suffers, in such cases you could try to reconnect to the desired device by clicking on it, but this is not always successful.

I've found as a workaround that sometimes is easier to reconnect if you reach another device or emulator first and then the desired one, so as a rule of thumb is probably better to always have more than one.

Anyway, here you are a very simple trick that might turn you life a little easier just using a text logcat from adb in a gnome-terminal that will remain open no matter what have happened to the connection.

First, you need to create a gnome-terminal profile, logcat in this case, an set the following values as dispalyed:


The important things here are:

  • Run a custom command instead of my shell
  • Custom command: sh -c '/opt/android-sdk/platform-tools/adb -e logcat | coloredlogcat.py'
  • When command exits: Hold the terminal open
As a bonus, we are including coloredlogcat.py, a filter that will colorize our logcat output.
What's nice about this simple setup is that even if you are disconnected because you closed the emulator or unplugged the device, just clicking on the Relaunch button will reconnect you again.


Hope you enjoy it and improve your development not having to insistently click on DDMS'  device list.
Post a Comment