Adb for "dummies"

Thursday, July 2, 2009
#still being written.

Too many noobs popping up on xda and none can read. hopefully they can read this.

Windows Users:

First lets download the android sdk files located here. (some /sdk/filepaths might be different from yours to mine, since ive modified my sdk a bit)

Once downloaded go ahead and make a folder in C:\ named something like C:\asdk\ and put all the file's from the sdk into that folder, this way you dont have to do a lot of typing in comand prompt, but to save you even more time copy "adb.exe" and "adbwinapi.dll" from what should be "C:\asdk\tools\" and paste those into "C:\windows\" this way when you open comand promt {windows key + r / or start>run>cmd} all you have to do is type adb and everything works out the way it should. test it to make sure it works ofcourse type "adb" and it should give you a list of commands that it can do.

Android Debug Bridge version 1.0.20

-d (directs command to the only connected USB device returns an error if more than one USB device is present.)
-e (directs command to the only running emulator. returns an error if more than one emulator is running.)
-s (directs command to the USB device or emulator with the given serial number.)
-p (simple product name like 'sooner', or a relative/absolute path to a product out directory like 'out/target/product/sooner'. If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used, which must be an absolute path.)


device commands:

adb devices - lists all connected devices
adb push - copy file/dir to device
adb pull - copy file/dir from device
adb sync [ ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell - run remote shell command
adb emu - run emulator console command
adb logcat [ ] - View device log
adb forward - forward socket connections
forward specs are one of:
tcp:
localabstract:
localreserved:
localfilesystem:
dev:
jdwp: (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport

adb install [-l] [-r] - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
adb uninstall [-k] - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.

adb help - show this help message
adb version - show version num

DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition

scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints:
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write

networking:
adb ppp [parameters] - Run PPP over USB.
Note: you should not automatically start a PDP connection.
refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ ]
can be interpreted in several ways:

- If is not specified, both /system and /data partitions will be u
pdated.

- If it is "system" or "data", only the corresponding partition
is updated.


now with all that said. make sure you have the adb drivers, they're posted in the sdk if you have the new spl, you'll more than likely need the drivers posted here. there shouldn't be a reason why your phone wont connect to adb with the drivers listed. so with that said lets move on.

Commands( used while typing adb shell)
Like DOS the command "cd" (change dir) is used to move through the file system;
cd data
cd app

will take you to /data/app, you can also type cd /data/app which will take you to the same area, and wildcards work here too, if you get an error it means you either there is no file/dir with that name or there is more than one file/dir that starts/ends with the wildcard)

so you wanna know what files are listed in the dir that you are in? typing "ls" (l as in lizard) will show all files (those with out the . before the name); "ls -a" will show every file/dir even ones listed with . infront (hidden files); "ls -l" will show the chmod level, size, datemodified, and name and more.

how to mount /system/ for read/write:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
(if doing this from terminal you'll need to type su, then the command above.

so you wanna add files to the phone from adb? typing adb push C:\path\to\file\filename.ext /sdcard/ will place the file root of the sdcard, i prefer this way than directly into the phone /system/ because from adb shell; you can just cp /sdcard/filename.ext /system/

so you want to remove files from your phone? - adb shell rm /path/to/file/NameOfAPK.apk
(file/dir names are case sensitive so make sure you spell it right, or if you're lazy you can use wild cards known as * , like so, rm /path/to/file/NameO* and anything that begins with NameO will be removed , same goes for ending with; rm /path/to/file/*OfAPK.apk, anything that ends with OfAPK.apk will be removed.)

this will conclude the data for today, will post more later; if you have questions please ask.

7 comments:

Horizontal Paul said...

I am trying to access my G1 through ADB so I can bypass the No Sim screen and turn on my WiFi to go through the registration to get to the Home screen.. I just get No Device Found

Paul

Anonymous said...

looks interesting

Spilii said...

Haha nice man. check out my blog sometime

ReS said...

Drivers dont work on my desire.

Leviathan said...

Finally a good guide for ADB Shell Commands Thankyou.

Anonymous said...

ADB For Dummies On XDA Forum

Another good ADB Guide for Noobs
It also has an All in one App

ADB For Dummies AIO APP

Anonymous said...

Hi can you give me the code to write in ADB if I want to install all my apk files.. from one folder on my computer.

if it is important my folder is on my desktop and it is called. toinstall

I want to install them all at once time
thank you to anyone who could help me