android adb cmd

查看屏幕分辨率

adb shell wm size

查看dpi

adb shell dumpsys window | grep ‘dpi’

WIFI调试:

  1. adb tcpip 5555
  2. adb connect 设备ip
    注意,USB拔插会断掉,所以插上USB后再 adb connect 设备ip。【注意】华为手机自建热点的ip一般是192.168.43.1

adb获取root

  1. adb root
  2. adb remount

adb 查看当前应用包名

adb shell dumpsys window | grep mCurrentFocus

查看一个activity所关联的service

adb shell dumpsys activity s [package-name]
例如:adb shell dumpsys activity s dji.go.v4

proguard gui

在 ~/Library/Android/sdk/tools/proguard/bin 下面

查看一个应用的内存情况

dumpsys meminfo [package-name]

当有多个设备时,adb选择指定设备

adb -s [serial-number] [cmd]

查看系统中所有已安装的包

adb shell pm list packages -f

查看系统中运行的进程

adb shell ps (旧版android的ps是toolbox版本的ps)
adb shell ps -A (新版android的ps换成了toybox版本的ps)

杀死一个应用程序

adb shell am force-stop [package-name]

查看当前的activity

adb shell logcat | grep ActivityManager
adb shell dumpsys activity activities

模拟用户按home键把app退到后台,然后系统因资源不足而杀死app,

此时用户再通过应用列表回到app,此时app已经死掉,但是activity栈还在,

因此系统拉起的是退出时的activity,而不是重新走一遍app启动流程

adb shell
su
kill [pid]

查看当前activity所在的task

adb shell dumpsys activity activities
在其中搜索 ‘Running activities’,其中的 TaskRecord 就表示一个 task 堆栈

获取当前手机的危险权限

adb shell pm list permissions -d -g

am启动应用并统计启动时间

adb shell am start -W -n [package name]/[launcher activity的全限定名]
adb shell am start -W -n dji.go.v4.debug/dji.pilot.main.activity.DJILauncherActivity

查看AndroidManifest.xml中信息总汇

aapt d badging [Your apk’s path]

adb logcat 出现EOF

adb logcat -G 2m

清除logcat缓存空间

adb logcat -b all -c

发生anr,获取traces.txt

adb pull data/anr/traces.txt

proguardgui反混淆

java -jar ~/Library/Android/sdk/tools/proguard/lib/proguardgui.jar

内存使用情况

adb shell dumpsys meminfo [package name] -d

adb 模拟触摸屏幕(人工操作经常一按就很多 MOVE)

adb shell input swipe [source.x] [source.y] [dst.x] [dst.y] [duration/ms]
例如 adb shell input swipe 300 1400 300 1420 1

查看包名

adb shell pm list packages -f | grep ‘xxx’

以 attach debugger 启动 app

让调试器 attached 上后采取执行 Application 的启动:adb shell am set-debug-app -w --persistent dji.mimo.debug
使用 adb shell am clear-debug-app 来清理

IMEI

adb shell getprop persist.sys.factory.imei

猜你喜欢

转载自blog.csdn.net/zengxx1989/article/details/128363518
今日推荐