你不知道的adb,熟知工具快速开发

磨刀不误砍柴工,作为Android开发四年多,我们平时可能做一些我们熟知的技术,比如ui开发或者其他.但是回头发现之前发现的小技巧,可能曾发现过,但没去记录并记住.很多时候我们回头想想这些小技巧会帮助我们提高很多开发效率,而不是去找搜索引擎浪费时间.
其中最近发现的有系统的快捷键或开发工具的快捷键,然后还有adb操作指令.这里只讲后者,快捷键的后边有机会再说.当然内容都是从网络整理的.
adb shell dumpsys window displays 获取屏幕分辨率
输出类似如下信息:
WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)
Display: mDisplayId=0
init=1080x1920 440dpi cur=1080x1920 app=1080x1920 rng=1080x1025-1920x1865
adb shell wm size
Physical size: 1080x1920
adb shell wm density
Physical density: 320 默认的dpi
adb shell getprop dhcp.wlan0.ipaddress 获取ip
192.168.0.107
设备名称
adb shell getprop ro.product.device
Ulike2
adb shell getprop ro.product.model
U705T
db shell getprop ro.product.name
oppo17_12035
adb shell getprop ro.serialno 序列号
0000012035ABCXXX
adb shell getprop ro.sf.lcd_density
240
adb shell dumpsys activity 获取Activity信息
adb shell dumpsys activity
加上-h可以获取帮助信息
获取当前界面的UI信息,可以用:
adb shell dumpsys activity top
要获取当前界面的Activity:
adb shell dumpsys activity top | findstr ACTIVITY
adb shell dumpsys cpuinfo 获取cpu消息
adb shell dumpsys package
adb shell dumpsys package PACKAGE_NAME 获取某个包的信息:
aapt dump badging xxxx.apk |findstr “package” 查看APP的Package
adb shell pm clear com.xxx.abc(app的package) 清除手机App的缓存
adb shell am start -n 启动app com.xxx.activity(package)/com.xxx.activity.AppStartActivity(main activity)
adb shell am start -a android.intent.action.CALL -d tel:10086 打电话
adb shell input tap 500 500 点击坐标
adb shell input keyevent 4 返回键
adb shell /system/bin/screencap -p /sdcard/screenshot.png 截图保存
adb shell screenrecord /sdcard/test.mp4 录屏
adb shell input swipe 700 2000 700 1000 上下滑动
adb shell input swipe 100 1000 1000 1000 左右滑动
adb shell service call bluetooth_manager 6 //打开蓝牙
adb shell service call bluetooth_manager 9 //关闭蓝牙
adb logcat -v time 打印日志详细时间的简单数据
adb logcat *:E 打印级别为Error的信息
adb logcat -v time *:E
adb logcat -v time >D:\log.txt将日志保存到电脑固定的位置
adb logcat | grep -E ‘1/(TAG1|TAG2)’ grep 正则表达式
adb logcat | grep -i myapp #忽略大小写
adb logcat | grep -v “…MyApp|…MyActivity” 过滤不需要的输出,加一个 -v 即可。例如要过滤 tag 为 MyApp 和 MyActivity 的输出
adb logcat -v threadtime -s umengsocial -v threadtime
查看日志的输出时间和线程信息
adb logcat -v process -s umengsocial


  1. VDE ↩︎

发布了17 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/caizehui/article/details/103754062
今日推荐