Adb使用过程中涉及到
Adb shell 进入shell模式,使用adb shell top 会实时刷新进程信息,control+C ,可以退出刷新到adb shell,然后输入exit 可进入到用户操作模式
https://github.com/mzlogin/awesome-adb
1.打开.bash_profile
bogon:~ baishuang$ open -e .bash_profile
2.SDK路径
bogon:~ baishuang$ cd Library/Android/sdk/
3.使用uiautomatorviewer出错,无弹窗
显示:
【bogon:bin baishuang$ uiautomatorviewer
-bash: uiautomatorviewer: command not found
解决:bogon:bin baishuang$ open uiautomatorviewer
结果:可以打开,原因不明。OPPO A30可以打开,360 n6打不开原因在于手动打开USB调试。
注:uiautomatorviewer必须在sdk目录下打开/Users/baishuang/Library/Android/sdk/tools/bin
参考链接 https://www.cnblogs.com/lazytest/p/5612709.html
4.adb命令使用
(1)bogon:~ baishuang$ adb -s 1cb6c69b shell wm size
Physical size: 1080x2160
注:-s 1cb6c69b 为连接多台设备时指定目标设备序列号
(2) adb version 查看版本号
(3) adb无线连接手机设备(360 n6)
手机电脑运行到同一局域网-USB连接电脑-5555端口监听
bogon:~ baishuang$ adb tcpip 5555(端口监听)
bogon:~ baishuang$ adb connect 10.254.111.169(连接手机Ip)
connected to 10.254.111.169:5555
bogon:~ baishuang$ adb devices
List of devices attached
10.254.111.169:5555 device
bogon:~ baishuang$ adb disconnect 10.254.111.169
disconnected 10.254.111.169
bogon:~ baishuang$ adb devices
List of devices attached
注:通过无线方式可以连接成功,但是open uiautomatorviewer却显示找不到设备
5.查看包
bogon:~ baishuang$ adb shell pm list packages (所以)
bogon:~ baishuang$ adb shell pm list packages -3 (第三方)
bogon:~ baishuang$ adb shell pm list packages | grep qi (管道过滤只包含qi的包)
6.安装包
bogon:~ baishuang$ adb install -r /Users/baishuang/Downloads/mobile-dev-v2.9.7-debug.apk
Success
指定某一设备安装
bogon:~ baishuang$ adb -s 368c3a2a install /Users/baishuang/Downloads/ydd-website-v1.5.1- release\(1\).apk
/Users/baishuang/Downloads/ydd-website...d. 6.9 MB/s (19173963 bytes in 2.637s)
pkg: /data/local/tmp/ydd-website-v1.5.1-release(1).apk
Success
7.清缓存
bogon:~ baishuang$ adb shell pm clear com.qiku.music
Success
8.查看当前Activity
bogon:~ baishuang$ adb shell dumpsys activity activities | grep mFocusedActivity
mFocusedActivity: ActivityRecord{f9f3168 u0 com.fengjr.mobile/.act.impl.Gesture t55}
9.查看安装目录
bogon:~ baishuang$ adb shell pm path com.fengjr.mobile
package:/data/app/com.fengjr.mobile-2/base.apk
10.查看 CPU信息
bogon:~ baishuang$ adb shell cat /proc/cpuinfo
11.查看正在运行的services
bogon:~ baishuang$ adb shell dumpsys activity services com.fengjr.mobile
12.唤起activity
bogon:~ baishuang$ adb shell am start -n com.fengjr.mobile/.act.impl.Main_ //凤金首页
Starting: Intent { cmp=com.fengjr.mobile/.act.impl.Main_ }
Warning: Activity not started, its current task has been brought to the front
13.停止某个应用
ogon:~ baishuang$ adb shell am force-stop com.fengjr.mobile //包名
14.滑动解锁,或上下滑动
bogon:~ baishuang$ adb shell input swipe 300 500 300 1000
300 500以及300 1000 为开始、结束的坐标