C:\Users\Administrator>adb devices
List of devices attached
142159d4e31740e0 device
2、adb kill-server:杀死adb连接进程3、adb start-server:开启adb进程
C:\Users\Administrator>adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
C:\Users\Administrator>adb install C:\Users\Administrator\Desktop\Test.apk
1473 KB/s (514647 bytes in 0.341s)
pkg: /data/local/tmp/Test.apk
Success
C:\Users\Administrator>adb uninstall com.dsw.test
Success
6、adb push localpath remotepath:将本地指定路径的apk推送到系统某路径下。
C:\Users\Administrator>adb push C:\Users\Administrator\Desktop\Test.apk system/app
failed to copy 'C:\Users\Administrator\Desktop\Test.apk' to 'system/app/Test.apk
': Read-only file system
2026 KB/s (514647 bytes in 0.248s)
C:\Users\Administrator>adb shell
root@sabreauto_6q:/ #
1|root@sabreauto_6q:/ # mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
none /sys/fs/cgroup tmpfs rw,relatime,mode=750,gid=1000 0 0
tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/shm tmpfs rw,relatime,size=1024k,mode=775,uid=1013,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
pstore /sys/fs/pstore pstore rw,relatime 0 0
/dev/block/mmcblk2p5 /system ext4 ro,relatime,data=ordered 0 0
/dev/block/mmcblk2p4 /data ext4 rw,nosuid,nodev,noatime,nodiratime,noauto_da_all
oc,data=ordered 0 0
/dev/block/mmcblk2p6 /cache ext4 rw,nosuid,nodev,relatime,data=ordered 0 0
/dev/block/mmcblk2p7 /device ext4 ro,nosuid,nodev,relatime,data=ordered 0 0
adb /dev/usb-ffs/adb functionfs rw,relatime 0 0
none /sys/kernel/debug debugfs rw,relatime 0 0
/dev/block/vold/179:9 /mnt/media_rw/sdcard0 vfat rw,dirsync,nosuid,nodev,noexec,
relatime,uid=1023,gid=1023,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,i
ocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:9 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relat
ime,uid=1023,gid=1023,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iochar
set=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/fuse /storage/sdcard0 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1
023,default_permissions,allow_other 0 0
root@sabreauto_6q:/ # mount -o remount -o rw /system
root@sabreauto_6q:/ # exit
这样我们就完成权限修改,再次执行adb push指令时就不会遇到失败。如下:
C:\Users\Administrator>adb push C:\Users\Administrator\Desktop\Test.apk system/app
1278 KB/s (514647 bytes in 0.393s)
255|root@sabreauto_6q:/ # cd /system/app
root@sabreauto_6q:/system/app # rm test.apk
rm failed for test.apk, No such file or directory
255|root@sabreauto_6q:/system/app # rm Test.apk
root@sabreauto_6q:/system/app #
C:\Users\Administrator>adb shell
root@sabreauto_6q:/ # cd /data/data
root@sabreauto_6q:/data/data # ls
com.android.backupconfirm
com.android.bluetooth
com.android.borqs.music
com.android.borqs.sleep
com.android.borqs.standby
root@sabreauto_6q:/data/data # pm list packages
package:com.systemupdate
package:com.borqs.taskmanager
package:com.android.defcontainer
package:com.android.launcher
package:com.iflytek.afadapter
package:com.borqs.gpsvalidation
package:com.android.contacts
package:com.tservice.positionreport
package:com.android.phone
C:\Users\Administrator>adb logcat -s dsw
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
D/dsw (24553): dsw:0
D/dsw (24553): dsw:1
D/dsw (24553): dsw:2
D/dsw (24553): dsw:3
D/dsw (24553): dsw:4
D/dsw (24553): dsw:5
D/dsw (24553): dsw:6
D/dsw (24553): dsw:7
D/dsw (24553): dsw:8
D/dsw (24553): dsw:9
D/dsw (24553): dsw:10
使用
adb logcat | grep TAG
也可达到效果
4、执行命令:adb logcat,会有无数条Log快速生成在控制台上,那么这时就有同学会问,如果吧一大堆Log抓下来一个一个E去找是十分不方便的,于是我们引进了强大的正则表达式:grep。例如查看Error级别的日志。adb logcat | gerp ^E
常见指令集合:
获取序列号:
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 //比如:adb install baidu.apk
保留数据和缓存文件,重新安装apk:
adb install -r //比如:adb install -r baidu.apk
安装apk到sd卡:
adb install -s // 比如:adb install -s baidu.apk
卸载APK:
adb uninstall //比如:adb uninstall com.baidu.search
卸载app但保留数据和缓存文件:
adb uninstall -k //比如:adb uninstall -k com.baidu.search
启动应用:
adb shell am start -n
查看设备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
从设备复制文件到本地:
adb pull
列出目录下的文件和文件夹,等同于dos中的dir命令:
adb shell ls
进入文件夹,等同于dos中的cd 命令:
adb shell cd
重命名文件:
adb shell rename path/oldfilename path/newfilename
删除system/avi.apk:
adb shell rm /system/avi.apk
删除文件夹及其下面所有文件:
adb shell rm -r
移动文件:
adb shell mv path/file newpath/file
设置文件权限:
adb shell chmod 777 /system/fonts/DroidSansFallback.ttf
新建文件夹:
adb shell mkdir path/foldelname
查看文件内容:
adb shell cat
查看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