adb常用命令

adb logcat:查看手机的日志信息,在出现bug的时候可以通过这个命令帮助定位查看
adb shell :进入Android终端命令,然后可以通过一些命令来查看手机相关信息
adb push: 向手机发送文件
adb pull :从手机获取文件
将 Android 设备上的文件或者文件夹复制到本地
例如复制 Sdcard 下的 pull.txt 文件到 D 盘:
adb pull sdcard/pull.txt d:
adb shell am start -W 包名/界面名:查看应用启动时间
adb install apk文件:通过adb命令行安装app
adb uninstall 包名 : 通过adb命令行卸载app
adb --help :查看adb 命令帮助信息
adb shell pm list package :查看所有包名
adb shell monkey –p 包名 –v 测试次数 :指定应用进行monkey测试
adb shell monkey –p 包名1 –p 包名2 –v 测试次数 :指定多個应用进行monkey测试
adb shell pm clear 包名:清理数据和重置权限
adb shell monkey:运行Monkey进行稳定性测试
adb start-server:启动adb服务
adb kill-server:终止adb服务
adb shell dumpsys cpuinfo 查看CPU情況
adb shell dumpsys meminfo 查看當前系統的內存
adb shell dumpsys meminfo 應用名 查看某個應用的內存
adb shell top
adb shell top | grep “包名” 查看某個包的一些性能指標
adb shell top -d 1 | grep “包名”
adb shell dumpsys battery 電池電量

adb shell monkey 次數 日誌信息最少
adb shell monkey -v 次數
adb shell monkey -vv 次數
adb shell monkey -vvvv 次數 日誌信息最多
adb shell monkey -p 包名 --throttle 間隔時長(秒)
adb shell monkey -p 包名 --pct-motion 20 --throttle 間隔時長(秒) 設置觸摸事件為20%
–pct-touch 觸摸事件
–pct-motion 滑動事件
–pct-trackball 軌跡球事件
–pct-nav 導航事件
–pct-tnajornav 主要導航事件
–pct-syskeys 系統按鍵事件
–pct-appswitch action之間的切換事件
–pct-pinchzoom 縮放事件
–pct-rotation 屏幕旋轉事件
–pct-flip 鍵盤事件
–pct-anyevent 任意事件

adb shell ps | grep monkey 查看進程
kill -9 進程id 殺死進程

种子數用於復現場景 -s

忽略異常:
–ignore-crashes 忽略異常
–ignore-timeouts 忽略超時
–ignore-security-exceptions 忽略安全異常
–kill-process-after-error 發生錯誤後直接殺掉進程
–dbg-no-events 初始化啟動的activity,但是不產生任何事件
–hprof 指定該項後在事件序列發送前後會立即生成分析報告
–monitor-native-crashes 跟蹤本地方法的崩潰問題
–wait-dbg 直接連接了調試器才執行monkey測試
–bugreport 當ANR,系統無響應,Crash的時候獲得bugreport

保存monkey日誌:
adb shell monkey 1000 > 文件名 包含事件的日誌
adb logcat -v time ‘*E’ > 文件名 可以進行過濾

日誌分析關鍵字
crash 閃退
exception 異常
force closed 強制退出
anr 程序無響應

adb shell logcat > d:\logcat.txt 把eclipse中logcat窗口的日志信息保存到文件中

下面的命令是将日志信息输出到已经存在的指定文件中
adb logcat > C:\Users\twl\Desktop\log\logcat.log
adb logcat -c //清空以前bai的日志
打印指定APP日志到文件中
C:\Users\user>
adb logcat | findstr com.example.up2service >D:\up.txt

输出某个包名APP的日志到文件中
C:\Users\user>
adb logcat | findstr com.example.up4 >D:\up.txt

adb logcat -v time > D:\up.txt //将当前bai日志输出到dud盘的sss.log中zhi sss.log不存在会自动创建,存在则覆盖dao原有的

adb logcat -s “xxx” //输出当前以xxx为TAG的日bai志, 过滤日志的 LOG.i(“xxx”,“YYYYY”)
adb logcat -s “MainActivity”
adb logcat -s “upphoto” > D:\up.txt
adb logcat -s “Haoxueren” > D:\up.txt

获取系统版本:adb shell getprop ro.build.version.release
获取系统api版本:adb shell getprop ro.build.version.sdk

adb pull /mnt/sdcard/2020-04.log D:\log

adb pull /mnt/sdcard/ D:\log
adb pull /mnt/sdcard/2020-04.log D:\log

adb pull /mnt/sdcard/Android/data/mqtt_t.app/files/YSLog/ys_logs.txt D:\log

adb pull /mnt/sdcard/Android/data/mqtt_t.app/files/YSLog/2020-04.log D:\log

adb pull /mnt/sdcard/Android/data/mqtt_t.app/files/YSLog/ D:\log

adb pull /mnt/sdcard/Android/data/mqtt_t.app/files/ D:\log

adb pull /data/local/tmp/mqtt.apk/2020-04.log D:\log
adb pull /data/data/mqtt_t.app/files/ D:\log
adb pull /data/data/mqtt_t.app/files/2020-04.log D:\log

adb pull /data/data/file_persistence.app/ D:\log

adb push D:\android\ec_lv1_workspace\eqpt\bin\eqpt.apk /system/priv-app/com.example.eqpt

安装应用
adb install C:\Users\user\Desktop\new\mqtt.apk

查看已安装的应用
adb shell pm list packages

查看第三方应用
adb shell pm list packages -3

卸载应用
adb uninstall mqtt_t.app

adb connect 172.16.11.121

运行apk
adb shell am start -n mqtt_t.app/.Mqtt_tActivity

adb shell am start -n testWifi.app/.TestWifiActivity

关闭apk
adb shell am force-stop mqtt_t.app

=============================================


连接adb
adb connect 172.16.34.191

导出日志文件
adb pull /mnt/sdcard/Android/data/mqttTable.app/files/YSLog/ D:\log

adb logcat > d:/log.txt

adb pull /mnt/sdcard/Android/data/mqttTable.app/files/ D:\log

查看Android版本
adb shell getprop ro.build.version.release

adb 設置Android代理
adb shell settings put global http_proxy 172.16.11.30:3128
移除代理
adb shell settings delete global http_proxy

查看已安装的应用
adb shell pm list packages

安装app
adb install C:\Users\user\Desktop\new\mqttTable.apk

adb install C:\Users\user\Desktop\new\zz.apk

adb install C:\Users\user\Desktop\new\table.apk

adb install C:\Users\user\Desktop\new\dashboard.apk

adb install C:\Users\user\Desktop\new\powerbi.apk

adb install C:\Users\user\Desktop\new\FDC.apk

adb install C:\Users\user\Desktop\new\service.apk

adb install C:\Users\user\Desktop\new\Diary.apk

adb install C:\Users\user\Desktop\new\myconndb.apk

adb install C:\Users\user\Desktop\new\listview.apk

adb install C:\Users\user\Desktop\new\firefox.apk

adb install C:\Users\user\Desktop\new\web3.apk

adb install C:\Users\user\Desktop\new\l_feng_jiao_look.apk

adb install D:\wwx\new\l_gujing_look.apk

adb install D:\wwx\new\firefox.apk

adb install D:\wwx\new\and_web.apk
adb install D:\wwx\apk\my_apk\and_web.apk

卸载app
adb uninstall com.example.and_web

启动app
adb shell am start -n com.example.eqpt/.MainActivity

关闭app
adb shell am force-stop mqttTable.app

打印内存信息
adb shell dumpsys meminfo mqttTable.app

查看当前运行包名
adb shell dumpsys window w |findstr / |findstr name=

jarsigner -verbose -keystore feelyou.keystore -storepass feelyou.info -signedjar reservice.apk -digestalg SHA1 -sigalg MD5withRSA service.apk feelyou

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

adb install D:\wwx\apk\disa.apk

adb 对时指令
adb shell setprop persist.sys.timezone Asia/Shanghai
adb shell settings put global ntp_server 172.16.4.254
adb shell reboot
查看对时服务器
adb shell
date
settings get global ntp_server

获取app包名、启动类名(待测试 app 应用已运行)
方法一:adb shell dumpsys activity activities | findstr “Run”
方法二:adb logcat | find “START”(推荐)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值