Setting Up ADB: Android Debug Bridge
Setting Up ADB: Android Debug Bridge
Logcat:-
A real time log of what is happening in background of our devices. It is really useful for developers to see
which component has malfunctioned and helps to narrow down their search for what failed and what needs
to be fixed. Several times users are asked to give logcats of their devices which are giving errors. We will
go in detail that how to get logcats in every and easiest way possible.
Shell Execution:-
You must have heard of Terminal Emulator. It is an app for android to execute shell commands(linux
commands) which are basically present as applets in /system/bin, /system/sbin or /system/xbin(in our case)
folders. A very imporant applet called busybox is installed there mainly used for execution of basic
commands during root browsing or ROM installation. Many times updater script of ROMs use busybox
commands to install it. Well, these commands can be initiated from your device too but they can be
initiated from adb also making it easy for programmers.
Basic commands:-
Of-course basic commands such as rebooting and rebooting in recovery mode and download mode are
supported.
Others:-
There are several other features of adb such as fastboot, aapt, etc
Setting up ADB
Pre Requirements:-
PC(This is a windows guide, if asked I will add linux and mac guide later)
Java Runtime environment or Java Developing kit
Your Device Drivers
An Android Device
USB Debugging MUST be turned ON in the device for ADB to see it & Developer options is hidden
in Android 4.2 and
above, Hitting Build number 10 times in
About Phone/Tablet reveals the menu (Thanks lilHermit for reminding me to add it)
Start
1. First Download Android SDK. Roughly about 70 MB
3. Now to get adb and other tools, you need to download 'Platform Tools'
To download them, go to the android-sdk folder and double click on SDK Manager
It will ask you which package to download? However, it is your choice which
package to Download, but here, we will only talk about platform
Tools. So, simply tick on Platform Tools and click on install. Once you have done
it. Go to the platform-tools folder in the directory where you installed android-sdk.
You will find several files there like adb, fastboot, aapt, etc
4. Now, you can backup the whole folder of android-sdk to any external storage
that will make you not download package
again if you want to. You can have it placed in any computer and run it as it does
not require registry to work
5. Now, you are just one step away from using adb. Next step is SKIPPING
SETTING ENVIRONMENT VARIABLE (If you however want to set
environment variables. Click on Show Content)
Many guides on internet say that it is to be done for making it easy for users and if
you have some basic knowledge of Command Prompt,
you will know that to execute any application with command prompt, you first
need to change the directory to the one where application is
placed. And to skip changing the directories every time you open CMD, you need
to put that application is environment variable. However, we will not do so.
6. Type cmd in the search bar. Copy cmd.exe from there. Go to the directory where
you have installed android-sdk. Go to platform-tools folder. Paste cmd there, right
click on it and in the settings, select Run as Administrator.
ADB Commands
Type adb in command prompt. And several commands will show up on your screen. It is very
difficult to analyse these all commands, so we will only talk about most used and important
commands
And open the CMD in platform-tools folder(Make a shortcut of it on desktop). And type the suitable
commands
Code:
adb devices
Will show the list of devices attached to the PC andtheir serial numbers. If this shows up correctly on your
PC, then it means that everything is fine for continuing.
Logcat
Code:
adb logcat
It will display the real time log of your device
Best time to do it is when your device boots up
Now, many users ask me how to copy the logcat and upload it from CMD
Code:
This command will create a logcat.txt document in platform-tools folder with the complete logcat of the
device. Ofcourse you can type any name instead of logcat.txt
3. I prefer taking logcat this way as it neatly compiles logs of different time
Code:
Installing Apps
Code:
Code:
Be sure your apk is not in a folder that has space in its name, else the command will break at space bar.
For eg:-
G:\Program Files\AreeB.apk
Note:
If you have spaces in path of apk, you can execute the command without
breakage if you include the path inside quotes. (Thanks to etcman)
Eg:-
Code:
Mounting
However, I never found any problem in tweaking with system files with adb, but some users said that they
couldn't do it, so the problem was that their system partition was mounted as Read Only(R/O)
So, it is necessary now to tell how to mount system partition as Read Write(R/W)
Code:
adb remount
For pushing,
Type
Code:
Code:
More examples
G:\Dance.txt file to be pushed in Dance folder in sdcard
Code:
adb push G:\Dance.txt /sdcard/Dance/
OR
Code:
For pulling,
Example,
All system apps are to be pulled to G:\ROM\system\app
Code:
However, if a folder is in platform-tools folder, you don't need to type full path
Suppose if I type
Code:
Then a folder named system will be created inside platform-tools with all the files in system in it
If a file is in platform-tools folder, then also no need to type full path
For example,
There is an app name DeskClock.apk in this folder then, to push it to /system/app, type
Code:
adb shell
adb commands won't work here and a new set of commands will work here. But we will only go in a little
detail here.
Assuming you are in adb shell mode, I will only type commands that will work on shell. Note:- These
commands won't work if you type them alone on cmd. But, these command will directly work on your
mobile's Terminal Emulator
As these commands can also work on mobile, I am going to tell you a way of taking logcat on mobile
Type
Code:
logcat
To save this
Type
Code:
Uninstalling Applications
Code:
cd /data/app
Code:
ls
Suppose, there is an app named com.opera.browser (Opera Mobile) you want to uninstall it
Type
Code:
rm -r com.opera.browser
Mounting Command:-
Code:
Miscellanous commands:-