ADB 全称Android Debug Bridge 是一个功能非常强大的工具,它位于Android SDK安装目录的platform-tools 子目录下,ADB工具即可完成模拟器文件与电脑文件的相互复制,也可安装APK应用,甚至可以直接切换到Android系统中执行部分Linux命令
1、查看当前运行的模拟器,设备:
adb devices
2、切换adb shell终端为root用户:
adb root
3、链接adb tcp接口或者usb串口:
adb connect 192.168.10.252:5555 (tcp 5555端口)
adb connect 93048d8f
4、启动shell
adb -s 192.168.10.252:5555 shell
如果adb devices 下只有一个设备则只需要:
adb shell 即可
5、安装apk文件
adb -s 192.168.10.252:5555 install [-r] [-s] [-t]<file>
-r 强制安装
-s 标示将APK包安装到SD卡上 默认是将APK安装到内部存储器上
-t 如果 报错 Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI] 可以使用该参数
6、卸载apk
adb uninstall [-k] <package>
-k 标示只删除该应用程序,但保留该程序素有的数据和缓存目录。
7、重新挂载文件系统,用来可以读写system等目录
adb -s 192.168.10.252:5555 remount
or
mount -o remount rw/dev/block/mtdblock0/system /
8、复制文件到手机
adb push a.txt /sdcard/
9、拷贝文件到电脑
adb pull /sdcard/xyz.txt d:/
10、重启设备
adb -s 192.168.10.252:5555 reboot
11、重启设备到bootloader模式
adb -s 192.168.10.252:5555 reboot bootloader
12、启动指定的app的页面
adb -s 192.168.10.252:5555 shell am start -n com.android.settings/.Settings
com.android.settings 应用程序的包名
.Settings 类名(Activity)
13、模拟点击坐标
adb -s 10.0.0.245:5555 shell input tap 250 500
x:250 px Y:500 px
14、滑动触摸事件
adb -s 10.0.0.245:5555 shell input swipe 200 500 400 500
#向右滑动200像素
15、修改屏幕尺寸
adb -s 10.0.0.245:5555 wm size 1080x1920
#修改屏幕尺寸为1080x1920
adb -s 10.0.0.245:5555 wm size
#查看屏幕默认尺寸