codeofaninja
website

ADB Command Basics and Setup Tutorial

Photo of Mike Dalisay
Modified Monday, May 20, 2013
by - @ninjazhai
Contents:

3.0 How to run the ADB?

     3.1 Open Command Prompt 
     3.2 Find adb.exe

4.0 ADB Commands

     4.1 adb
     4.2 adb devices

          4.2.1 adb kill-server
          4.2.2 adb start-server

     4.3 adb shell

          4.3.1 ls
          4.3.2 exit
          4.3.3 cd
          4.3.4 rm
          4.3.5 cp

     4.4 adb push
     4.5 adb pull
     4.6 adb install
     4.7 adb reboot
     4.8 adb reboot recovery
     4.9 adb logcat

Recently, I was asked to flash a custom ROM to several Android devices that Samsung seems to forget to update. These devices include:

-Galaxy Tab 10.1 (GT-P7500) - Upgraded from Android 3.2 Honeycomb to 4.2 Jelly Bean

-Galaxy Tab 8.9 (GT-P7300) - Upgraded from Android 3.2 Honeycomb to 4.2 Jelly Bean

-Galaxy Mini (GT-S5570) - Upgraded from Android 2.3 Froyo to 4.1 Jelly Bean
I was delighted seeing these old devices run with the Jelly Bean OS.

Please note that I actually have no plans of posting how to root and upgrade certain devices here in our blog. (But if many of you insists, I may change my mind haha!)

This is because there are already a lots of resources on other sites, especially in the XDA-Developers forum.

In my experience, rooting and flashing a custom ROM to your device may take a lot of trial and error. One blog post may not work for you, so you have to look on other blog post or forums and maybe combine their instructions or installation files for your device to work.

So, this tutorial will just cover some ADB commands that I learned and can be useful when doing such tasks. This list can be your reference too!

If you think I missed something on this list, please feel free to leave a comment below and I'm more than willing to udpate this post.

1.0 What is ADB?


First off, for those who have no idea what ADB is, ADB stands for Android Debug Bridge. Basically, it is a command line interface that lets you communicate from PC to your Android device or emulator.

On windows, it is an .exe file where you can execute some commands (see section 4.0 below) with the help of command prompt (cmd.exe).

2.0 Where can I get ADB?


I used the ADB from the Android ADT Bundle we installed, yes it is with the Android developmenet environment files. I actually wrote a post regarding its installation. You can find it in the path: YourADT_Folder > sdk > platform-tools > adb.exe

3.0 How To Run The ADB?


Easy, just follow the steps below:

3.1. Open your command prompt. On windows, you can type on the search box "cmd.exe" and then press enter. It will pop up a really cool black window.

cmd.exe

3.2 Find your adb.exe - go to your ADT folder > sdk > platform-tools

Copy the path, go back to the black window, right click then paste it there. After pasting, press enter. See screenshots below:

adb.exe location on my PC. Click to enlarge.

To paste  the path, just do a right click and select "Paste"

After pasting, press you enter key. Now you're insde the adb directory.
Enjoy the ADB commands below. :D

4.0 ADB Commands


4.1 Make sure ADB is working by typing the "adb" command (see the yellow underline below). The output will look like this:


4.2 Know what Android devices were attached on your computer by typing the "adb devices" command.


      4.2.1 If it can't connect to your device, first, you have to do an adb   kill-server command

      4.2.2 And then, do an adb   start-server command, and re-execute adb   devices

4.3 Begin a shell connection with your Android device by typing the "adb shell" command. More about shell here.


     4.3.1 Know what files and directories are in your Android device by typing the "ls" command



     4.3.2 If you think you're done with the shell connection, you can exit it by typing the "exit" command, and now you're out of the shell mode.


     4.3.3 Change directories by using the "cd" command. Sample use:

              cd    /sdcard/my_folder

     4.3.4 If you want to remove a file from your device, here's the "rm" command. Sample use:

              rm    /sdcard/my_folder/my_text_file.txt

     4.3.5 copy file from one directory to another with the "cp" command. Sample use:

     cp    /sdcard/my_old_folder/my_text_file.txt    /sdcard/my_new_folder/my_text_file.txt

4.4 Copy file from PC to android device using the "adb push"

File to be pushed.

Execute the command.
File were pushed on the Android device.
4.5 Get file from Android device to your PC by using the "adb pull" command. Sample use:

      adb   pull   /sdcard/my_file.zip   c:\my_file.zip

4.6 If you have an APK installer file in your PC, you can also install it using the ADB via "adb install" command. Sample use:

      adb   install   c:\your_app.apk

4.7 adb   reboot command will simply reboot your Android device.

4.8 adb   reboot   recovery will reboot your device in recovery mode.

4.8 adb  logcat is useful when you're making an app and debugging. Eclipse also provide this functionality.

The Code of a Ninja Resources

For FREE programming tutorials, click the red button below and subscribe! :)
Thanks for the comments!
 
 
Fundamentals
"First do it, then do it right, then do it better."
~ Addy Osmani
"Talk is cheap. Show me the code."
~ Linus Torvalds
Let's Stay Connected!
g+ r
Android app on Google Play
© 2011-2014 The Code Of A Ninja. All rights reserved. Proudly Powered by Google Blogger. Images, logos, marks or names mentioned herein are the property of their respective owners.