ADB installation and how to logcat

One of the most important tools in Android is the ADB (short for “Android Debugging Bridge”). This tool comes together with the Android SDK. Even more important is its logcat tool. Logcat is very useful when it comes to identifying errors and problems in Android. However, since logcat is an ADB tool, it is loaded AFTER the kernel and init is loaded. That said, it is excellent in resolving issues AFTER the kernel has loaded. Lets dig into how to get ADB installed and running the logcat. Thankfully, ADB supports al three major platforms – Linux, MacOSX and Windows.

Step 1 : Download the Android SDK from here. Link opens in a new window.

Step 2 : Extract the downloaded ZIP file to a location you will remember.

Step 3 : Include the tools path to the global variable (explained below)

Adding Variables


A. Using Command Prompt (cmd)

  1. Hit the “Start” button. Select “Run..” then type “cmd” or just type “cmd” if you are using beyond Win XP.
  2. Once the cmd has opened, assuming you have extracted the package to C:\AndroidSDK and the tools folder location is at C:\AndroidSDK\tools, type this command in the cmd. You may need to alter the bold text.

set PATH=%PATH%;c:\AndroidSDK\tools

B. Using Graphical User Interface (GUI)
If command prompt is not your thing, there is an easier method to do this. Follow the steps:

For WinXP

  1. Right click on My Computer
  2. Select Properties
  3. Select the Advanced Options tab
  4. Click the Environment Variables
  5. Click the edit button of the path
  6. Add the location C:\AndroidSDK\tools at the end of the variables string. Note : You may notice other environment variables in this field too. They should be separated with a semicolon “;“.

For WinVista and Win7

Step 4 : Run the SDKSetup.exe in the Android SDK folder and you should see your SDK version listed as installed in the window.

Step 5 : Now go to settings and check the box that says “Force https:// … to Be fetch sources using http:// …” and then select “Save & Apply”.

Step 6 : Now go to “Available Packages” and hit the “Refresh” package. Mark the listed packages and then hit “Install Selected” button.

That’s it! Now the SDK has been successfully installed. Now, since ADB is a “debugging” tool, you need to allow debugging on the phone too. To do this, on your phone, go to the following location:

Settings -> Applications -> Development

Check the “USB Debugging” box.

Executing ADB

Now, run the cmd / Terminal application again. Type the following command:

adb devices

If you see your device listed, it means everything is working perfectly.

Running Logcat

Now, to create a logcat, this is the command that you may execute:

adb logcat > logcat.txt

The whole logcat log will be saved at the path that you ran this command at. For example, if you ran this command when your prompt was at C:\Desktop>, then it will be saved at C:\Desktop\logcat.txt. This logcat.log file can then be used to identify the problem that is occuring. To stop the log, press ( ctrl + . ) ctrl key with the period key.

If you are filing a logcat for force close, you should start the logcat using the command above first, then initiate the force close action, then stop the logcat. This way, the force close instance will be captured within the log and can be sent to the developers accordingly.

Other useful ADB commands

ADB has a bunch of very useful commands that you can use for various purposes. Here are some of them that you might find handy.

Questions? Suggestions? Appreciation? Feel free to comment.


Tags: , , , , , , , , ,