adb 常用的命令总结

1、adb logcat 抓取日志

adb logcat > d:\log.txt

Ctrl+c 结束日志抓取

adb logcat -c > d:\log.txt 清空旧日志

发生Native Crash 时,抓取错误报告

adb logcat -b crash

抓取筛选后的日志: adb logcat -s AndroidRuntime > d:\log.txt

抓取所有LOG命令:adb logcat --v time > D:\log.txt

抓取应用层LOG命令:adb logcat --b main --v time >D:\main.txt

抓取死机、重启LOG命令: adb shell dumpsys > d:/dump.txt

更多抓取日志命令参考 https://blog.csdn.net/wenzhi20102321/article/details/105861354

https://www.bilibili.com/read/cv10022202/

2、查看系统进程

adb shell ps

adb shell ps | find "包名" 过滤指定进程

3、使用命令行安装apk包

如果是连接了多个设备的话,就需要指定设备:adb -s 设备编号 install apk的完整路径

如果是单设备,可以输入 adb install apk的完整路径;

如:adb install C:\Users\31210\Downloads\XXX.apk,

覆盖安装:adb install -r xxxx.apk强制安装(覆盖安装时使用)

卸载包: adb uninstall 安装包包名

adb install -r ,-d

adb install -r 替换已存在的应用程序,也就是说强制安装

adb install -l 锁定该应用程序

adb install -t 允许测试包

adb install -s 把应用程序安装到sd卡上

adb install -d 允许进行降级安装,也就是安装的比手机上带的版本低

adb install -g 为应用程序授予所有运行时的权限

4、打开android 系统设置页面

adb 启动应用

adb shell am start -n 包名/包名.ui.activity.MainActivity

adb shell am start -n package/launch activity

adb shell am start com.android.settings/.Settings

adb shell am start -n com.android.settings/.Settings$DevelopmentSettingsDashboardActivity

adb shell am start -a android.settings.SETTINGS

adb shell am start -a android.settings.BLUETOOTH_SETTINGS

com.android.settings/.Settings$WifiAddActivity

联想设备系统应用

adb shell am start -n com.android.deskclock/.DeskClock 时钟

adb shell am start -n com.android.calculator2/.Calculator 计算器

打开系统应用访问权限页面

adb shell am start -a android.settings.USAGE_ACCESS_SETTINGS

5、打开网络adb 调试

adb tcpip 5555 (端口号)

adb connect 10.135.192.30(Android 设备IP地址)

断开网络adb调试

adb disconnect 10.135.192.30

6、查看所有已安装的软件包 adb shell pm list packages

查看系统包名 adb shell pm list packages -s

查看第三方安装包 adb shell pm list packages -3

adb shell pm list packages -f 输出包和包相关联的文件(安装路径)

adb shell pm list packages -i 输出包和安装信息(安装来源)

adb shell pm list packages -e 只输出启用的包

查看所有被停用的软件包 adb shell pm list packages -d

列出应用包名及对应的apk名及存放位置 adb shell pm list package -f

禁用系统内置应用:adb shell pm disable-user 应用包名

开启系统内置应用:adb shell pm enable 应用包名

screencap 截图命令 adb shell screencap -p /sdcard/screen.png

screenrecord4.4 录制命令 adb shell screenrecord sdcard/record.mp4

清除app缓冲

adb shell pm clear com.shensz.student

7、输出包和安装信息(安装来源) adb shell pm list packages -i

8、强杀进程 adb shell am force-stop 包名

查看当前设备所运行的包名 ,activity名

adb shell dumpsys window | findstr mCurrentFocus

adb shell dumpsys activity activities | grep -i run

查看应用版本号

adb shell pm dump com.google.android.inputmethod.pinyin | findstr version

9、获取设备属性信息: getprop

adb shell getprop ro.product.manufacturer # 获取设备的厂商, 例如: HUAWEI

adb shell getprop ro.product.brand # 获取设备的商标, 例如: HUAWEI

adb shell getprop ro.product.model # 获取设备的型号, 例如: BLA-AL00

adb shell getprop ro.build.version.release # 获取设备的 Android 版本, 例如: 8.1.0

adb shell getprop ro.build.version.sdk # 获取设备的 SDK Version, 例如: 27

adb shell getprop ro.boot.serialno # 获取设备的序列号, 例如: 8FE0917B20005668

adb shell getprop ro.board.platform # 获取设备的 CUP 平台, 例如: kirin970

adb命令参考

https://blog.csdn.net/xietansheng/article/details/86675136

https://juejin.cn/post/6844903645289398280?utm_campaign=sembaidu\&utm_medium=sem_baidu_jj_pc_dc01\&utm_source=bdpcjjwz04776

10、adb 查看apk V1 V2签名

D:\Sdk\build-tools\29.0.2>apksigner verify -v C:\Users\yuhang\Desktop\FCDeviceGuard_1.00.28.apk

11、android 通过WIFI调试和adb指令推送文件到安卓设备

通过adb指令推送文件到设备

adb push D:\honor_logs.txt /sdcard/

12、adb shell dumpsys activity activities #查看当前activity 所对应的ActivityRecord task栈结构

adb shell dumpsys activity | findstr mResumedActivity 查看当前栈顶可见Activity名

adb shell命令查看当前与用户交互的前台Activity

adb shell dumpsys activity | grep -i run 列出的是你打开的页面(以最近打开为先进行排序)

adb shell dumpsys activity top | grep ACTIVITY 列出的是你打开的页面(倒序方式排序)

adb shell dumpsys window | grep mCurrentFocus

adb shell dumpsys window

adb shell dumpsys window | findStr "WINDOW"

adb shell dumpsys window | findstr mCurrentFocus 可以分析当前所处的页面和activity,可以 快速定位activity信息

adb shell dumpsys window -h adb shell dumpsys window w | findstr mCurrent

更多名称参考:https://www.jianshu.com/p/10cbdb6bbc2f

查询四大组件和进程

1.查询某个App所有的Service状态

adb shell dumpsys activity s com.android.settings

2.查询某个App所有的广播状态

adb shell dumpsys activity b com.android.settings

3.查询某个App所有的activity状态

adb shell dumpsys activity a com.android.settings

3.查询某个App所有的process状态

adb shell dumpsys activity p com.android.settings

adb shell dumpsys activity top 当前界面app状态

dumpsys activity oom 查看进程状态

https://www.jianshu.com/p/10cbdb6bbc2f

查看AMS cached清理设置

adb shell dumpsys activity settings (https://www.cnblogs.com/1118zjg/p/16009908.html)

查看系统是否低内存(MemFree 和 MemAvailable 的值会很小)

adb shell cat proc/meminfo

只能查看java 进程

adb shell procrank

13、adb shell am start -W 包名/包名.ui.activity.MainActivity app 启动时间

更新相关命令参考链接: https://www.cnblogs.com/Free-Thinker/p/14596179.html

14、查看仅授予的权限(但忽略被请求但未被授予的权限)

adb shell dumpsys package com.ckl.launcher

更多参考链接:https://www.cnblogs.com/endv/p/11695330.html

15、adb 查看Android设备上的分区信息

C:\Users\yuhang>adb shell

X6C6F:/ $ df

,adb shell 进入linux命令行

4, adb 查看设备分辨率

C:\Users\yuhang>adb shell

X6C6F:/ $ wm size

输入wm density 查看dpi

16、adb 清除应用数据和缓冲

adb shell pm clear 包名

https://blog.csdn.net/roland_sun/article/details/50969958

17、

adb shell ls mnt 查看所有设备存储设备名

adb remount 将 system 分区重新挂载为可读写分区

adb push 从本地复制文件到设备

adb pull 从设备复制文件到本地

adb shell ls 列出目录下的文件和文件夹

adb shell cd 进入文件夹

adb shell rm [-r] 删除文件(夹)

adb shell cat 查看文件内容

adb shell mkdir path/foldername 新建文件夹

https://www.it610.com/article/1298639711610404864.htm

18、adb查看应用程序内存使用情况

adb shell dumpsys meminfo <package_name>

adb shell dumpsys cpuinfo

adb shell dumpsys cpuinfo <package_name>

19、android ANR

-- 抓取bugreport 分析

adb shell bugreport 存放目录

--导入anr trances 分析

adb bugreport 不指定,默认为当前目录)

--BugReport 分析利器 ChkBugReport

https://www.lxiaoyu.com/p/329163

https://dev.mi.com/distribute/doc/details?pId=1127

20、adb 查看android手机中应用的包名和安装位置

-查看包安装位置

$ pm list packages -f

-查看包安装位置,并进行筛选

$ pm list packages -f | grep tencent

=========window 查询DNS记录及域名解析命令==========

1、查询DNS记录及域名解析命令

nslookup baidu.com

2、读取本地DNS缓冲内容(查看操作系统自身的DNS缓存)

ipconfig/displaydns

2.1 查看Chrome自身的缓存 chrome://net-internals/#dns

3、本地DNS缓冲清理

ipconfig/flushdns

DNS正向解析和反向解析

https://blog.csdn.net/qq_29677867/article/details/92586932

https://blog.51cto.com/13706760/2142598

4、读取Windows系统hosts文件: C:\Windows\System32\drivers\etc

=========window 查询DNS记录及域名解析命令==========

5、android iptables 命令

iptables的工作原理 https://www.cnblogs.com/wangkangluo1/archive/2012/04/19/2457072.html

https://www.jianshu.com/p/c500dc5a13b0

https://www.jianshu.com/p/63aed7a9ca53

https://blog.csdn.net/qq_21816375/article/details/80546303

1、查看防火墙是否关闭

iptables -nvL

2、查看防火墙上的可用规则

iptables -t filter --list

查看mangle表:

iptables -t mangle --list

查看NAT表:

iptables -t nat --list

查看RAW表:

iptables -t raw --list

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

命令_查看占用端:

windows:netstat -ano | findstr 8001(端口号)

更多命令参考:

https://blog.csdn.net/qq_26941173/article/details/80372733

10.135.192.176

抓系统日志:

adb shell am start -n com.debug.loggerui/com.debug.loggerui.MainActivity

adb pull data/debuglogger

adb shell am start -n com.android.settings/.SubSettings

联想启用系统日志页面

在设置里的搜索框 输入####3333#

再通过 adb shell am start -n com.debug.loggerui/com.debug.loggerui.MainActivity

导出 anr traces

adb pull data/anr

DropBoxManagerService 收集Crash异常

1、adb shell

cd /data/system/dropbox

ls -alt

参考链接:https://blog.csdn.net/a953210725/article/details/107562158

2、adb shell dumpsys dropbox

adb shell dumpsys dropbox --print 2023-03-27 14:06:49 data_app_crash

adb shell dumpsys dropbox --print 2023-03-27 14:06:49 system_app_crash

3、adb shell ls -l /data/system/dropbox

激活设备管理器 device owner

adb shell dpm set-device-owner 包名/ 包名.device.receiver.GuardAdminReceiver

adb shell dpm remove-active-admin com.android.jarvis/.receivers.JarvisAdminReceiver

查看apk 是否debug 包

adb shell dumpsys package 包名 | findstr flags

查看Android 设备上的服务进程是否存在

adb shell dumpsys activity services | grep -i "service"

相关推荐
阿巴斯甜14 小时前
Android 报错:Zip file '/Users/lyy/develop/repoAndroidLapp/l-app-android-ble/app/bu
android
Kapaseker14 小时前
实战 Compose 中的 IntrinsicSize
android·kotlin
xq952715 小时前
Andorid Google 登录接入文档
android
黄林晴16 小时前
告别 Modifier 地狱,Compose 样式系统要变天了
android·android jetpack
冬奇Lab1 天前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读
城东米粉儿1 天前
Android MediaPlayer 笔记
android
Jony_1 天前
Android 启动优化方案
android
阿巴斯甜1 天前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇1 天前
AOSP15 Input专题InputReader源码分析
android
_小马快跑_2 天前
Kotlin | 协程调度器选择:何时用CoroutineScope配置,何时用launch指定?
android