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
Windows
A. Using Command Prompt (cmd)
- Hit the “Start” button. Select “Run..” then type “cmd” or just type “cmd” if you are using beyond Win XP.
- 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
- Right click on My Computer
- Select Properties
- Select the Advanced Options tab
- Click the Environment Variables
- Click the edit button of the path
- 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
- Right click on Equipment
- Select Properties
- Select Advanced System Settings
- Select Advanced Options
- Click the Environment Variables
- Click the edit button of the path
- 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 “;“.
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.
- adb push <local path> <destination path> - Pushing files to the phone from computer. eg: adb push C:\Desktop\file.zip /sdcard/file.zip
- adb pull <remote path> <destination path> - Pulling files from the phone to the computer. eg: adb pull /sdcard/file.zip C:\Desktop\file.zip
- adb shell - Provides shell access to the phone. Very useful to execute root commands.
- adb install <APK path> - Install applications from your computer. eg: adb install C:\Desktop\app.apk
Questions? Suggestions? Appreciation? Feel free to comment.
Shahz
-
#3 written by bignate78 (1 year ago)
-
- Comment Feed for this Post







Hello shahz,
I’m new to this android stuff, so bear with me if I have a few questions.
1) At the Android SDK website, there are two files, one an installer and the other is not. If I use the installer file, then I can bypass step 3 above?
2) The installer says that Java SE Development Kit is not available. At the Java download site, there are 2 files available, a x32 & x64 bit version. I’m running Windows 7 x64 bit. Should I install both or just the x64 version?
Thanks in advance.