常用命令
-
连接模拟器
adb connect <device_ip_address>:<port>
失败返回结果:failed to connect to <device_ip_address>:
成功返回结果:connected to <device_ip_address>: -
切换adb shell终端为root用户
adb root
-
显示连接到计算机的所有 Android 设备列表
adb devices
-
进入设备的命令行 shell
adb shell
-
安装一个应用程序
adb install <path_to_apk>
-
卸载一个应用程序
adb uninstall <package_name>
-
将本地文件复制到设备
adb push <local> <remote>
-
从设备上复制文件到本地
adb pull <remote> <local>
-
重新启动设备
adb reboot
-
启动指定包中的指定活动
adb shell am start -n <package_name>/<activity_name>
-
停止正在运行的ADB守护进程
adb kill-servers
-
强制停止应用程序
adb shell am force-stop <package_name>
常见问题
-
adb: unable to connect for root: more than one device/emulator或者adb.exe: more than one device/emulator 都是提示当前连接的模拟器设备不止一台
解决方法:执行命令行adb kill-server,关掉所有连接,然后重新执行adb connect
-
remount of the / superblock failed: Permission denied
解决方法:开放模拟器磁盘写功能,上一篇文章有提到