(adb) is a tool that lets you manage the state of an emulator instance or Android phone. ADB is bundled with Android SDK package that can be downloaded from Android SDK download page. This tool is usefull for communicating with Android phone such as install application, copy files from/to device and perform some linux shell commands.
How to Install
Download and install
Java SDK(Ex:jdk-6u20-windows-i586.exe)
Download
Android SDKpackage (Ex:android-sdk_r06-windows.zip)
Extract SDK package into anywhere on your drive (Ex: D:\android-sdk-windows)
Phone Setup
In order to use ADB, you have to enable USB Debugging option in phone settings (Settings->Applications->Development)
How to Use
- Connect the phone to your pc/notebook usb port
- Run Windows command line tool (cmd) and go to D:\android-sdk-windows\tool
Update!!
New Android SDK puts adb executable file on \platform-tools directory instead of tool. So the path should be D:\android-sdk-windows\platform-tools
Usefull Commands
1. Check connected phone
Syntax: adb devices
2. Login to Android shell
Syntax: adb shell
Note:
If you get ‘#’ after typing adb shell, you are already get root access on the phone, no need to type su. Otherwise if you get ‘$’ , type ‘su’ to get root access (only for rooted device).
3. Some usefull shell commands
-
ls
List directory
Syntax: ls [path]
Example:
#ls /system/lib
-
cp
Copy file or directory
Syntax: cp [options] source dest
To copy or delete files in Android root directories you have to change the directory access mode to ‘read and write (rw)’ using command: remount rw
#remount rw
#cp /sdcard/libsec-ril.so /system/lib
#remount ro
-
mv
Move file or directory
Syntax: mv [options] source dest
#mv /system/lib/libsec-ril.so /sdcard/backup
-
chmod
Change file/directory permission
Syntax: chmod [-R] mode[,mode] …. file
#chmod 0644 /system/lib/libsec-ril.so
-
rm
Remove file or directory
Syntax: rm [options] file
#rm /system/lib/libsec-ril.so
4. Install application
You can use adb to install aplication from your local drive into phone.
Syntax: adb install appname.apk
D:\android-sdk-windows\tools\adb install D:\AnReboot.apk
5. Copy files from phone to local drive
Syntax: adb pull source [destination]
D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip
D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip D:
6. Copy files from local drive to phone
Syntax: adb push source destination
D:\android-sdk-windows\tools\adb push D:\AnReboot.apk /sdcard
To See The Original Link Please Click Here-
擷取序列号:
adb get-serialno
-
檢視連接配接計算機的裝置:
adb devices
-
重新開機機器:
adb reboot
-
重新開機到bootloader,即刷機模式:
adb reboot bootloader
-
重新開機到recovery,即恢複模式:
adb reboot recovery
-
檢視log:
adb logcat
-
終止adb服務程序:
adb kill-server
-
重新開機adb服務程序:
adb start-server
-
擷取機器MAC位址:
adb shell cat /sys/class/net/wlan0/address
- 擷取CPU序列号:
adb shell cat /proc/cpuinfo
- 安裝APK:
adb install <apkfile> //比如:adb install baidu.apk
- 保留資料和緩存檔案,重新安裝apk:
adb install -r <apkfile> //比如:adb install -r baidu.apk
- 安裝apk到sd卡:
adb install -s <apkfile> // 比如:adb install -s baidu.apk
- 解除安裝APK:
adb uninstall <package> //比如:adb uninstall com.baidu.search
- 解除安裝app但保留資料和緩存檔案:
adb uninstall -k <package> //比如:adb uninstall -k com.baidu.search
- 啟動應用:
adb shell am start -n <package_name>/.<activity_class_name>
- 檢視裝置cpu和記憶體占用情況:
adb shell top
- 檢視占用記憶體前6的app:
adb shell top -m 6
- 重新整理一次記憶體資訊,然後傳回:
adb shell top -n 1
- 查詢各程序記憶體使用情況:
adb shell procrank
- 殺死一個程序:
adb shell kill [pid]
- 檢視程序清單:
adb shell ps
- 檢視指定程序狀态:
adb shell ps -x [PID]
- 檢視背景services資訊:
adb shell service list
- 檢視目前記憶體占用:
adb shell cat /proc/meminfo
- 檢視IO記憶體分區:
adb shell cat /proc/iomem
- 将system分區重新挂載為可讀寫分區:
adb remount
- 從本地複制檔案到裝置:
adb push <local> <remote>
- 從裝置複制檔案到本地:
adb pull <remote> <local>
- 列出目錄下的檔案和檔案夾,等同于dos中的dir指令:
adb shell ls
- 進入檔案夾,等同于dos中的cd 指令:
adb shell cd <folder>
- 重命名檔案:
adb shell rename path/oldfilename path/newfilename
- 删除system/avi.apk:
adb shell rm /system/avi.apk
- 删除檔案夾及其下面所有檔案:
adb shell rm -r <folder>
- 移動檔案:
adb shell mv path/file newpath/file
- 設定檔案權限:
adb shell chmod 777 /system/fonts/DroidSansFallback.ttf
- 建立檔案夾:
adb shell mkdir path/foldelname
- 檢視檔案内容:
adb shell cat <file>
- 檢視wifi密碼:
adb shell cat /data/misc/wifi/*.conf
- 清除log緩存:
adb logcat -c
- 檢視bug報告:
adb bugreport
- 擷取裝置名稱:
adb shell cat /system/build.prop
- 檢視ADB幫助:
adb help
- 跑monkey:
adb shell monkey -v -p your.package.name 500
-
通路資料庫SQLite3
adb shell
sqlite3