常见问题
1. adb 命令不可用
配置adb的环境变量。
adb_path = /sdk/platform-tools
2.adb Operation not permitted
使用root权限
adb root
adb remount 把system 设置为可写
-------------------------------------------------------------
1. 常用命令
* 开启服务
adb start-server
* 关闭服务
adb kill-server
列出设备及其id
adb devices
重启
adb reboot
* 随机测试
adb shell monkey -p your.package.name 1000
* script文件测试
adb shell monkey -f /sdcard/xxx.script
杀死应用
adb shell am force-stop com.noboauto.ecocarservice
adb shell kill pid
前台activity:分两步
adb shell
dumpsys activity top | grep Activity
获取内网ip
adb shell ifconfig|findstr Bcast
adb shell ip –f inet addr|findstr wlan0
adb devices #查看连接设备
adb install test.apk # 安装应用
adb uninstall cn.com.test.mobile #卸载应用,需要指定包
adb logcat #查看日志
adb logcat -c #清除log 缓存
adb logcat > D:\logcat.log #输出日志到文件里
adb reboot #重启
adb shell screencap -p /sdcard/01.png 截图设备屏幕
2. adb通过 Wi-Fi 连接到设备
(Android 10 及更低版本)
-
将 Android 设备和 adb 主机连接到这两者都可以访问的同一 Wi-Fi 网络。请注意,并非所有接入点都适用;您可能需要使用防火墙已正确配置为支持 adb 的接入点。
-
使用 USB 线将设备连接到主机。
-
设置目标设备以监听端口 5555 上的 TCP/IP 连接 adb tcpip 5555
-
拔掉连接目标设备的 USB 线。
-
adb connect device_ip_address:5555
-
确认主机已连接到目标设备:adb devices