Getting Started with Android Debug Bridge

 INTRODUCTION

So if you are so much in love with android, and considering that you are a power user at some point of time you might think, “What should I do to take my interest in Android on to a next level.”  Well, we are going to discuss just that. Simply surfing on your android phone using the GUI would feel very stock by this time. So, let’s do an upgrade on that.

Essentially what you might need is ADB. ADB provides you with a Unix Shell that lets you do a lot of thinks on your android phones simply by using sets of commands. Installing custom ROM’s, installing apk’s, Backing up phone data,etc….can be done just by using a set of commands on ADB.

If you have ever tried to back up your Android device’s whole data onto your computer, you might have pretty good get the idea of what I’m talking about. It is a very hefty task if you’re trying to simply copy files onto your PC you might end up having to deal with lots of errors while you try to restore your files back to your phone. If you are trying to use an app to back up and restore your file, you might most of the time end up with missing files most of the time . So, to sum it all up ADB simply uses a command not only take a backup of your whole data but also to store it on your computer as a zip file.

This example was just to illustrate one of the uses of ADB. There are lots of other uses for ADB and if you’re very interested to learn ADB you can check out Android Studios official website on ADB.

HOW TO INSTALL ADB?

I would be discussing how to install ADB on Ubuntu. (as that is the operating system I prefer. )

Installing ADB – it is a very simple process on Ubuntu open up the terminal by clicking Ctrl + T. Then, type in the command sudo apt-get install adb If you have done it correctly you can check if you have installed adb successfully by typing adb on the terminal, and something like this should show up  Screenshot from 2018-09-30 20-04-50

HOW DOES ADB WORK

ADB includes three components  1. A client 2. A daemon and 3. A server

  • Client

This is the tool that runs on your computer. The function of the client is to sent commands to your Android device by using command line or terminal. It takes advantage of the adb commands to do this.

  • Daemon

Daemon runs on your android device as a background process. The function of Daemon is to run the commands given by the Client.

  • Server

    The function of server is to act as a medium of communication between the Client and Daemon. The server works in your computer’s background.

ENABLE DEBUGGING ON YOUR PHONE

By default, android development mode is hidden on your phone. So to enable it,go to:

  • Settings > About phone
  • There you will find Build number
  • Tap on it seven times to enable Developer options.
  • Go to developer options and enable it.
  • Check USB debugging option and allow access on the pop-up dialogue box

GETTING STARTED

I prefer to use the USB cable to connect to my android devices as connecting to wifi might include a lot of issues and also it is not possible to do so in a work environment.

  1. Go to command line and type in adb start-server you should see something like this                                                                                                                                                    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
  2.  Type in adb devices                                                                                                                 If your device is listed then you are ready to go.
  3. Don’t for get to type in adb kill-server when you’re done working.

SOME BASIC THINGS TO DO ON ADB

Let’s start with some basic commands (these are the commands that I found useful)

  • adb install /home/angrybirds.apk 

    ( this command will install angry birds app to your Android device. the angry birds apk, in this case, is located on /home and hence the location is specified

  • adb uninstall package.com.rovio.angrybirds 

    (this commands uninstalls angry birds from your android device you can replace com.rovio.angrybirds with any package name of your choice to uninstall that package.)

  • adb push /home/music /sdcard

    (this command is used to copy files from your computer to your android phone here I have copied music folder from home hence the location /home/music to /sdcard of my android device. remember to put a space between the first location and destination location.)

  • adb pull /sdcard/music /home 

    (here I copied the music folder from my sdcard on android device to home on my computer)

  • adb logcat 

    (this function is used for debugging apps. It will show you your android Device’s logs on your terminal)

  • adb shell screencap /sdcard/screen.png 

    (you need to be in the shell of your adb in order to take a screenshot. Here this command would take a screen shot and save it on  /sdcard as a png file with name screen.png)

  • adb shell screenrecord /sdcard/video.mp4 

    (this will allow you to record a video of your screen and save it to /sdcard as an mp4 file with name video.mp4)

  • adb backup -apk -shared -all -f /home/backup.ab 

    (this will back up your whole device data to location/home as backup.ab)

  • adb restore /home/backup.ab 

    (this will restore your Android device data from the backup.ab file in location /home)

If you want more information on how to use adb and you want to get started on android development it is recommended to cheak out android development official site

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s