美文网首页
[Point] adb

[Point] adb

作者: simplehych | 来源:发表于2018-12-14 08:58 被阅读0次

adb: Android Debug Bridge
grep: global search regular expression and print out the line

  • 多个设备连接 adb -s serial_number command
$ adb devices
List of devices attached
N2F4C15602017859    device
emulator-5554   device

$ adb -s N2F4C15602017859 shell getprop ro.product.cpu.abi
arm64-v8a
  • 查看日志:
adb logcat | grep com.xxx > logcat
  • 查看手机进程
adb shell ps
adb shell ps | grep xxx
  • 查看cpu 类型 ABIs

adb shell getprop ro.product.cpu.abi
armeabiv-v7a / arm64-v8a / armeabi / x86 / x86_64

交互 input

  • 点击屏幕坐标
    eg: adb shell input tap 400 1000

  • 点击 Home 键 对应keycode
    eg: adb shell input keyevent 3

  • 滑动屏幕
    eg: adb shell input swipe 300 1000 300 500

  • 屏幕截取
    eg: adb shell screencap /sdcard/screencap1.png

  • 屏幕录制
    eg: adb shell screenrecord /sdcard/screenrecord1.mp4

  • 文件复制,手机(remote路径) -> 电脑(local路径) adb pull remote local

  • 文件复制,电脑(local) -> 手机(remote路径) adb push local remote

练习 groovy + adb

wifi 连接手机

  1. 通过 USB 电缆将设备连接到计算机

  2. 设置目标设备以侦听端口 5555 上的 TCP/IP 连接
    adb tcpip 5555
    执行完之后处理监听状态

    在此之前可以查看端口占用情况 lsof -i tcp:5555
    杀死进程 id : kill 5555
    杀死adb服务:adb kill-server

  3. 断开 USB 电缆连接

  4. 通过 IP 地址连接设备, IP 地址一般在 WLAN 高级设置里面
    adb connect device_ip_address

  5. 确认是否连接
    adb devices
    显示结果IP+port 的形式:device_ip_address:5555 device

Note:每次只能通过 wifi 连接一个设备

假如有多态模拟器/设备正在运行,在使用 adb 命令时必须制定一个目标实例。
adb -s serial_number command
eg: adb -s ip:5555 install helloWorld.apk adb -s emulator shell input keyevent 3

相关文章

网友评论

      本文标题:[Point] adb

      本文链接:https://www.haomeiwen.com/subject/owlwhqtx.html