Blog

How to collect logs from Android Devices?

Android Logs Collection

Logs and screenshots help developers understand and trace the bugs reported by testers. Logs are especially more useful in case of crashes. Logs are a stack trace of what happened when bug was observed or when an application crashed! They give inside details of processes and make it easy for developers to identify what went wrong.

In this blog, I will share some tips on collecting logs and other valuable information from android devices. There are multiple methods to collect logs from android devices. Some of those methods may work only with selected set of devices or with selected android versions. But the approach I am going to share over here is the one recommended by Google and will work in all scenarios.

First of all, we need to prepare our environment. Make sure you have done following steps before actually going to collect logs.

1. Download and configure Android SDK (Eclipse):

Android SDK can be downloaded from Android Developers website. It is better to set environment variables for Android SDK to utilize all debugging features provided by Android SDK.

Note:

I am assuming that you already have Java JDK installed in your system. If it is not, please get that from oracle website and install it as well.

2. Make sure OEM Drivers for Android Device are installed:

Most of the android device drivers will get automatically installed by your operating system (in my case, it is Windows 7). But there are some devices whose drivers do not get installed automatically. Before moving to any other step, you need to make sure that your device drivers are installed. If they are not, you need to find their drivers from internet (manufacturer’s website in most of cases) and install them manually.

3. Enable ‘Debug mode’ on Android Device:

To get logs from Android device, you will first need to enable ‘Android Debug Mode’ in Device settings menu. Normally, debug mode option is found in following path:

Settings > Application > Development > USB debugging
Settings > Developer Options > USB debugging

Note:

In Android 4.2.2+ / Nexus devices, Developer Options are hidden by default. You can unlock these options by going to settings > About Device and Tap on “Build Number” seven times.

On Kindle Fire HD, ‘Debug option’ can be enabled by going to Settings > Security > Enable ADB

After you have done all of above mentioned steps, then you are ready to collect logs from device. If you are going to collect logs for some specific app then make sure that developer have not set ‘android:debuggable’ to ‘false’ in its AndroidManifest.xml file.

In Android SDK, we have multiple options to collect log. We can use DDMS or Monitor.Bat or LogCat to observe logs, monitor network statistics, view system information and take screenshots etc.

At the moment of writing this blog, DDMS is most popular, but it is now being deprecated and Google recommends using Monitor.bat instead of it. Both Monitor.bat and DDMS.bat could be found in directory “android-sdk\sdk\tools\”. Just click on the “monitor.bat” file after connecting device with

system

. Android Debug Monitor will launch and you can see the connected device in ‘Devices table’ with online status.

 

Logs can be seen in Log cat tab as shown in the image. Android Debug Monitor enable us to filter these logs by different characteristics like ‘info’, ‘debug’, ‘error’ etc. There are many other helpful features as well like monitoring network statistics, system information, memory usage, taking screenshots and lot more, which you can explore yourself by using this wonderful tool for android debugging!

Do give it a try, and if you have any other useful tips, then please share them in comments section!