Jump to content
Reliance Jio & Reliance Mobile Discussion Forums
digitalnirvana

[Android Guide] ADB For Dummies

Recommended Posts

ADB is an acronym for Android Debug Bridge and is a development tool for the Android Mobile Operating System.

There are different ways to install adb on windows. Below listed two methods, the first method is "Complete", which involves installing the Android SDK (Software Development Kit), and the second "Quick" way. Either should be fine for rooting etc.

INSTALLING ADB ON WINDOWS - METHOD A, THE "COMPLETE" WAY, USING THE SDK

Step 1

Download and install USB drivers for your phone.

Step 2

Download and install the Android SDK (Software Development Kit) Starter package from http://developer.android.com/sdk/index.html

There are two choices for Windows there, a simple zip file which you can unzip somewhere appropriate on your PC (e.g. put it on C:\ if you like). Or there's an installer (which is the recommended option according to the Android website), though that forces you to download some Java stuff which we don't really need for adb and takes a lot longer to install (but there won't be any harm in getting).

If you downloaded a .zip or .tgz package (instead of the SDK installer), unpack it to a safe location on your machine. By default, the SDK files are unpacked into a directory named android-sdk-<machine-platform> e.g. android-sdk-windows.

You can read all about how to install the SDK at http://developer.android.com/sdk/installing.html . Ignore all the stuff about Eclipse though, you don't need that unless you're going to start writing Android apps.

Now, from version 8 (Android 2.3) of the SDK onwards, adb has been taken out of this starter package. If you downloaded version 7 (Android 2.2), then you've already got adb and you can skip Step 3 and go straight to Step 4 below. Otherwise you need to proceed to Step 3 to add adb to the SDK.

Step 3

Assuming you have version 8 of the SDK Starter package onwards, now we need to add the Platform Tools component to the SDK, because that contains adb.

Run "SDK Manager" on your PC. You will find that in the root directory of the SDK, so you can open up a file explorer window to find that, then double-click on "SDK Manager" to run it".

Wait for a few seconds while it checks on the Android website for updates etc, let it then pop up with a window showing you what is on offer.

Add the "Android SDK Platform Tools", you can "reject" (i.e. don't install) all the other things it offers you if you like, though there's no harm in installing them (just takes up disk space on your PC).

Step 4

Now we need to update your Path variable. This lets you run adb on your PC from a command window no matter which directory you are in (which makes things a lot easier). If you don't setup your Path, then every time you want to run adb, you will either have to type the whole long pathname where you put adb, or cd to where you've put adb and run it from there (which could be inconvenient if you are transferring files to/from your phone).

On your PC, right-click on "My Computer" and select "Properties". (on Vista, click on "Change Settings"). Go to the "Advanced" tab, then select "Environment Variables".

Find the "Path" variable in the list of variables that it shows (you might need to scroll), and then double-click on that entry to edit it. Add the full path of the "tools" and "platform-tools" folders of the SDK to your path. e.g. if the SDK has been installed in "c:\Program Files\android-sdk-windows", then add to the end of your Path ";c:\Program Files\android-sdk-windows\tools;c:\Program Files\android-sdk-windows\platform-tools" (Please Note - don't put any spaces between the semi-colon and pathname, otherwise it won't work !)

Click on OK to exit out of the dialog, then OK again to get out of My computer's properties. After you reboot your computer you'll have it set up.

Step 5

On your phone, go into Menu->Settings->Applications->Development and make sure you have the entry "USB Debugging" ticked. adb will not work without this.

Step 6

Plug your phone into your PC using the original USB cable. This is important, do not use a third-party cable since it might not work with adb (even though it might seem fine with other communication with your phone).

Step 7

Fire up a command prompt on your computer, e.g. "Run" then "cmd", or pick the "Command prompt" option from the menus, and type in the following (obviously the C:\> bit is your actual PC's prompt, not what you type). To emphasise, you are running this on your PC, not directly from your phone (e.g. terminal emulator) :

Code:

C:\&gt;  adb devices

This should display something like the following :

Code:

List of devices attached
XXX12345    device

... where the "XXX12345" bit is actually your phone's serial number. If the list is blank and the phone is plugged in ok, go back to Step 5 and make sure USB Debugging is enabled. If you can see your phone, then you're in business, adb can see your phone and communicate with it, and you're ready to start using adb !

By the way, the first adb command that you type may well also come up with some lines similar to "adb deamon out of date" etc, but don't worry, that's normal, just check the rest of the output.

INSTALLING ADB ON WINDOWS - METHOD B, THE "QUICK" WAY, NO SDK

Step 1

Download and install USB drivers for your phone.

Step 2

Download this zip archive and unzip it somewhere memorable on your PC (e.g. into a folder on your desktop) - http://dl.google.com/android/repository/platform-tools_r01-windows.zip

Step 3

On your phone, go into Menu->Settings->Applications->Development and make sure you have the entry "USB Debugging" ticked. adb will not work without this.

Step 4

Plug your phone into your PC using the original USB cable.

Step 5

Fire up a command prompt on your computer, e.g. "Run" then "cmd", or pick the "Command prompt" option from the menus.

Use the "cd" command to change to the folder that contains the adb.exe and other files that you unzipped in Step 2.

Then type in the following (obviously the C:\> bit is your actual PC's prompt, not what you type). To emphasise, you are running this on your PC, not directly from your phone (e.g. terminal emulator) :

Code:

C:\&gt;  adb devices

This should display something like the following :

Code:

List of devices attached
XXX12345    device

... where the "XXX12345" bit is actually your phone's serial number. If the list is blank and the phone is plugged in ok, go back to Step 3 and make sure USB Debugging is enabled. If you can see your phone, then you're in business, adb can see your phone and communicate with it, and you're ready to start using adb !

By the way, the first adb command that you type may well also come up with some lines similar to "adb deamon out of date" etc, but don't worry, that's normal, just check the rest of the output.

Source and credit: XDA

Edited by digitalnirvana

Share this post


Link to post
Share on other sites

INSTALLING ADB ON MAC

What you will need:

A Mac

USB cable

Android SDK for OSX - http://developer.android.com/sdk/index.html

This guide refers to the version "android-sdk_r08-mac_86".

So download the zip file and extract it to a folder where you are happy to keep it such as within your user home folder i.e. Macintosh HD/Users/{Your User Name} and for this guide the example folder is is Users/test.

Then open then still in Finder, open "android-sdk-mac_86" then "tools".

Now launch Terminal - ⌘ + space then type Terminal or Applications>Utilities>Terminal

Now drag and drop the file called "android" in the "tools" folder into your terminal window and you should see something like:

/Users/test/android-sdk-mac_86/tools/android

Then hit enter - this should load Android SDK

Next go to Available Packages on the left and Android Repository > Android SDK Platform-tools, revision 1 -tick the box and hit "Install Selected"

It should download and install the Platform Tools which includes ADB !!!!

Now quit Android SDK after it has downloaded and go back into Finder. Now you should see a new folder "platform-tools" in the "android-sdk-mac_86" folder. Open that and you can now see a file called adb.

Now go back to your Terminal window and type (or copy & paste):

Code:

cd ~

The screen should then look like

NAME_OF_YOUR_MACHINE:~ USERNAME$

For example:

Mac-Pro:~ test$

Next, type

Code:

touch .bash_profile

to create your new bash / path file

Next, type

Code:

open -e .bash_profile

to open it in TextEdit.

Now into Text Edit please copy:

Code:

export PATH=${PATH}:

Then go into Finder and navigate your your "android-sdk-mac_86" folder. Then click on the "platform-tools" folder and drag and drop this into TextEdit at the end of the code above that you copied. Mine looks like:

export PATH=${PATH}:/Users/test/android-sdk-mac_86/platform-tools/

Yours should look like:

export PATH=${PATH}:insert your path to the "platform-tools" folder in your Android SDK here

All you need is that one line. Then Save and exit TextEdit and then very importantly QUIT TERMINAL.

Now to turn on USB Debugging in your handset Settings > Applications > Development > USB Debugging - ticked and also go to Settings > Connect to PC > Default connection type > Charge Only and also UNTICK "Ask me ..." there also. You can always go back here and change these settings back.

Now plug in your phone to a USB port.

Now to launch ADB - re-open terminal (remember that you had quit it - very important!) then type in:

Code:

adb devices

And you should see:

List of devices attached

HXXXXXXXXXX device

where XXXXXXXX is your unique phone ID.

Now you can run all of your favourite ADB commands straight by typing:

Code:

adb shell

etc straight into Terminal.

Source and credit: XDA

Edited by digitalnirvana

Share this post


Link to post
Share on other sites

BASIC ADB COMMANDS

How to get your logcat

To use logcat simply

Code:

adb shell
logcat

To logcat to sdcard

Code:

adb shell
logcat &gt; /sdcard/logcat.txt

Copy an app from your phone to your computer

Code:

adb pull /system/app/filename.apk C:\path

(replace filename.apk with the app your pulling also replace path with the folder your placing the app in)

Install an app from your computer on your phone

This is also known as sideloading. Unlike installing from the SD card, it does not require unknown sources to be enabled.

Code:

adb install filename.apk

This assumes that you are working from the directory where the file is located. This will install the application to /data/app. It will also show sometimes useful errors if install fails. That is not something you will see from the Android GUI.

If you want to do anything which needs admin access, first we go to the adb shell which logs into the phone.

Code:

adb shell

If we end up with a $, we will want admin rights, in many cases. To get admin rights, you want to type

Code:

su

Look at your phone if this is the first time, it may prompt you to allow access. Else you will get permission denied.

If you are not rooted, this will not work

Push an app from your computer to your phones filesystem

Code:

adb push filename /pathtodirectoryonphone

So for instance, if I have test.txt that I want to send to root of /sdcard, I would type:

Code:

adb push test.txt /sdcard/

Pushing files can be done to any directory, however, some are protected.

For instance, /system is going to give you a permission denied or a read only filesystem error.

To get around this, the easiest thing to do is push the file to your sdcard, then log into the shell:

Code:

adb shell

Code:

su

We will then mount the system as writable

Code:

mount -o rw,remount /dev/block/stl9 /system

Then we can use something like

Code:

cp /sdcard/test.txt /system/app/test.txt

cp stands for copy and it requires the path of the file and destination path. When you copy it, you can rename it to whatever you like. For instance, if we wanted to backup a file

Code:

cp /sdcard/test.txt /sdcard/backuptest.txt

Pulling files from your phone to your computer

Lets say you want to get a file from your phone, to modify, backup, etc. To do this, we simply use adb in this manner:

Code:

adb pull /pathtofile/filename destinationname

For instance, if I wanted to backup ADW launcher in system/app I would do this

Code:

adb pull /system/app/ADWLauncher.apk ADWLauncher.apk

And it will pull the file from the phone and put it in the current directory. Like above, you can specifcy where it goes.

Changing permissions

We use something called chmod. This is used in this manner

Code:

adb shell
su
chmod 755 /pathtoapplication/applicationname

An example

Code:

adb shell
su
chmod 755 /system/app/ADWLauncher.apk

755 is good for applications and script files.

Remove an app from your phone

This becomes especially handy for removing rogue applications.

To do this, we must be in the adb shell.

Code:

adb shell
su
rm /system/app/ADWLauncher.apk

You may first need to remount system as writable with:

Code:

mount -o rw,remount /dev/block/stl9 /system

That applies when using chmod as well. So what I did above was delete ADW Launcher from system/app

Flash a recovery image to your phone

First pace the recovery image in your sdcard root and rename it to recovery (so the full name will now be recovery.img)

Code:

adb shell
su (prompt changes from $ to #)
flash_image recovery /sdcard/recovery.img (wait till this# sign shows up again before you type the next command)
reboot recovery

Get your current battery level

Code:

adb shell 
cat /sys/class/power_supply/battery/capacity 

Get your current rom build

Code:

adb shell 
getprop ro.build.description

If we want to merely reboot the phone

Code:

adb reboot

If we want to go to recovery

Code:

adb reboot recovery

Source and credit: XDA

Edited by digitalnirvana
  • Like 4

Share this post


Link to post
Share on other sites

^^ Thanks Dipan! This is very helpful for non-techies like me.

Share this post


Link to post
Share on other sites

Here are few utilities which allows adb functionality in GUI.

ANDROID COMMANDER

- copy multiple files/dirs between Phone and PC

- copy multiple files/dirs between Phone folders

- delete multiple files/dirs from Phone

- new dir and rename options

- drag&drop multiple files/dirs in to progrm

- drag&drop files/dirs between program tabs

- partitions size info

- bookmarks

- windows integration

- backup multiple apps to any dir on Phone/PC

- batch/single apps install

- install as private

- update

- batch/single uinstall apps

- uninstall with option to keep data or not

- type any shell command

- run sh script from PC

- flashing zip and img files

- options to reboot, reboot to recovery, reboot to bootloader, power off phone

- screenshots (beta)

- tools...

Sreenshot :

cover.PNG

Phone Requirements:

- ROOT (only for Applications Manager and flashing options)

- BusyBox (required only for rooted phones; included to most ROMs)

- Settings->Applications->Development->USB debuging must be enabled

- USB cable

PC Requirements:

- Windows

- Android SDK *

- Installed ADB USB Driver from Android SDK *

- SDK/Tools set in System Path *

*see post 1

Download:

Here

DROID EXPLORER

- Multiple Device Support

- Copy and auto-apply update.zip

- Copy local files to device

- Auto detection of connected/disconnected device

- APK file icon and extended information

- Device command shell window

- Reboot device

- Reboot device in to recovery mode

- Open files for viewing / execution locally with the default file type executable

- Drag & Drop file copy from Explorer

- Flash Recovery Image

- Package Manager (Install & Uninstall)

- No need to mount SD card to access files from computer

- Access files in other directories besides SD card

- Copy files from device to local clipboard

- Paste files from local clipboard to device

- Open files on local machine

- Display open with dialog to specify what to open a file with

- Right click APK and Uninstall

- Right click APK and Install

- Delete files from device

- Take a Screen Shot (landscape or portrait)

- Plugins can register as a component to open files

- Open from within Computer

- Should now work with more ROMs as long as they are Rooted and have busybox

- Device "Friendly Name" instead of device serial number.

- Android Screencast Plugin - Control your android device with your mouse and keyboard

- Install/Uninstall APK files right from explorer

- Standalone plugin runner (will mainly be used for windows 7 jump lists and the apk installer but can be used to run any plugin.

- Better Hero Support

- Backup the "Google Experience" applications and creates an update.zip containing the applications

- Use an existing Android SDK with Droid Explorer, or let Droid Explorer set up the SDK for you.

Screenshot:

Here

Download:

Here

Source: Modaco

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Dipan. +1 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×