相关命令
查看当前连接设备
1 adb devices
如果发现多个设备
1 adb -s 设备号 其他指令
安装命令
1 adb install path
ame.apk
覆盖安装
1 adb install path
ame.apk
卸载apk包
1.查看apk主包名
知道apk包名,反编译操作
1 D:>aapt dump badging jisuanqi_587.apk
2 package: name=‘com.ibox.calculators‘ versionCode=‘587‘ versionName=‘2.8.7‘ platformBuildVersionName=‘6.0-2704002‘
3 sdkVersion:‘14‘
4 targetSdkVersion:‘19‘
不知道apk报名,打开模拟器中的app
1 D:>adb shell dumpsys window | findstr mCurrentFocus
2 mCurrentFocus=Window{e66be70 u0 com.ibox.calculators/com.ibox.calculators.CalculatorActivity}
2.卸载操作
1 D:>adb uninstall com.ibox.calculators
2 Success
进入手机的超级终端
1 D:>adb shell
2 vbox86p:/ #
向模拟器中写入文件(上传文件)
首先需要知道俩个,1.windos下文件的路径及文件名称,2.上传至手机模拟器上的路径
1 adb shell find / -name 文件夹名称 -type d
开始上传
1 D:>adb push file_test.txt /data/media/0/Download
2 file_test.txt: 1 file pushed, 0 skipped. 0.0 MB/s (13 bytes in 0.002s)
注: file_test.txt 为当前D:下的文档,/data/media/0/Download 为手机路径
从模拟器中复制文件(下载文件)
1 D:>adb pull /data/media/0/Download/test/file_test.txt File
2 /data/media/0/Download/test/file_test.txt: 1 file pulled, 0 skipped. 0.0 MB/s (13 bytes in 0.001s)
注: /data/media/0/Download/test/file_test.txt 为手机路径, File 为电脑路径
查看app相关信息,包括action,codepath,version等等
1 adb shell dumpsys package com.ibox.calculators
查看app的路径
1 C:UsersAlin>adb shell pm path com.ibox.calculators
2 package:/data/app/com.ibox.calculators-JFzmL_qeOWqldw_nuBAG2A==/base.apk
启动app
先根据adb shell dumpsys window | findstr mCurrentFocus查找到
C:UsersAlin>adb shell am start -n com.ibox.calculators/com.ibox.calculators.CalculatorActivity
Starting: Intent { cmp=com.ibox.calculators/.CalculatorActivity }
删除与包相关的所有数据,清楚数据和缓存
1 C:UsersAlin>adb shell pm clear com.ibox.calculators
2 Success
查看某个app的进程相关信息
1 C:UsersAlin>adb shell ps|findstr com.ibox.calculators
2 u0_a102 3988 282 984300 106688 ep_poll f15f4bb9 S com.ibox.calculators:ghosty
3 u0_a102 4020 282 998936 107988 ep_poll f15f4bb9 S com.ibox.calculators:pushservice
4 u0_a102 4030 1 985296 22240 unix_stream_read_generic f15f4bb9 S com.ibox.calculators:ghosty
5 u0_a102 4059 282 1171828 215852 ep_poll f15f4bb9 S com.ibox.calculators
杀掉某个进程,一般用于模拟某个bug复现
1 C:UsersAlin>adb shell kill 5213
查看某一个app的内存占用
1 C:UsersAlin>adb shell dumpsys meminfo com.ibox.calculators
利用adb命令按住案件
1 adb shell input keyevent KEYCODE_BACK
相关命令可查看这个博客:https://www.cnblogs.com/bluestorm/p/4886662.html
查看日志命令
adb logcat [选项] [过滤项] (选项过滤项可填可不填)
-s:设置输出日志的标签, 只显示该标签的日志;
1 C:UsersAlin>adb logcat -s PackageManager
2 --------- beginning of main
3 --------- beginning of system
4 07-28 10:26:00.282 1091 1481 W PackageManager: Failure retrieving resources for com.ibox.calculators
-f:将日志输出到文件,该文件是在手机上的路径+文件名
1 C:UsersAlin>adb logcat -f /data/media/0/Download/test.log
-c:清空所有日志的缓存信息
1 C:UsersAlin>adb logcat -c
-v:
- adb logcat -v time :可以查看日志的输出时间;
- adb logcat -v threadtime :可以查看日志的输出时间和线程信息;
- adb logcat -v process:格式为“优先级 (进程ID) : 日志信息 "的日志;
- adb logcat -v tag:格式为 " 优先级 / 标签 : 日志信息" 的日志;
- adb logcat -v thread :格式为 "优先级 ( 进程ID : 线程ID) 标签 : 日志内容" 的日志;
- adb logcat -v raw :只输出日志信息, 不附加任何其他信息; adb logcat -v long:格式为 “ [ 日期 时间 进程ID : 线程ID 优先级 / 标签] 日志信息 ” 的日志。
过滤项解析
V : Verbose (明细); D : Debug (调试); I: Info (信息); W: Warn (警告); E: Error (错误); F: Fatal (严重错误); S : Silent(Super all output) (最高的优先级, 可能不会记载东西) 举例:1、显示 Error 以上级别的日志:adb logcat *:E1 C:UsersAlin>adb logcat *:W
1 C:UsersAlin>adb logcat -s System:E
2 --------- beginning of main
3 --------- beginning of system
4 07-28 10:37:40.043 6232 6410 E System : ******** DEPRECATED FUNCTIONALITY ********
5 07-28 10:37:40.043 6232 6410 E System : * The implementation of the KeyFactory.RSA algorithm from
6 07-28 10:37:40.043 6232 6410 E System : * the BC provider is deprecated in this version of Android.
7 07-28 10:37:40.043 6232 6410 E System : * It will be removed in a future version of Android and your
8 07-28 10:37:40.043 6232 6410 E System : * application will no longer be able to request it. Please see
9 07-28 10:37:40.043 6232 6410 E System : * https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html
10 07-28 10:37:40.043 6232 6410 E System : * for more details.
11 07-28 10:39:22.948 6232 6427 E System : ******** DEPRECATED FUNCTIONALITY ********
12 07-28 10:39:22.948 6232 6427 E System : * The implementation of the KeyFactory.RSA algorithm from
13 07-28 10:39:22.948 6232 6427 E System : * the BC provider is deprecated in this version of Android.
14 07-28 10:39:22.948 6232 6427 E System : * It will be removed in a future version of Android and your
15 07-28 10:39:22.948 6232 6427 E System : * application will no longer be able to request it. Please see
16 07-28 10:39:22.948 6232 6427 E System : * https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html
17 07-28 10:39:22.948 6232 6427 E System : * for more details.
adb命令使用
原文地址:https://www.cnblogs.com/ClownAlin/p/13393104.html