ADB命令汇总
安装apk
初次安装
adb install + "path_to_apk "
-lrtsdg
将应该安装到保护目录/mnt/asec
-l
覆盖安装
-r
允许安装AndoroidMainfest.xml里application指定android:testOnly=“true”的应用
-t
将应用安装到sdcard
-s
覆盖降级安装
-d
授予所有运行时权限
-g
卸载apk
adb uninstall -k “package name”
package name包名
表示保留数据和缓存目录
-k
输入文本
adb shell input text “内容”
清除缓存
adb shell pm clear “package name”
日志
打印日志
adb logcat *:W
日志优先级
V —— Verbose(最低,输出得最多)
D —— Debug
I —— Info
W —— Warning
E —— Error
F —— Fatal
S —— Silent(最高,啥也不输出)
按tag和级别过滤日志
adb logcat ActivityManager:I MyApp:D*:S
表示输出tag ActivityManager的Info以上级别日志,输出tag MyApp的Debug以上级别日志及其他tag的Slient级别日志
清空日志
adb logcat -c
内核日志
adb shell dmesg
adb shell logcat -v time > C:\Users\Administrator\Desktop\logcat.txt
进程
重启设备
adb reboot
查看进程
adb shell ps
查看版本/设备
adb version
adb devices
查看应用列表
所有应用
adb shell pm list packages
系统应用
adb shell pm list packages -s
第三方应用
adb shell pm list packages -3
强制停止应用
adb shell am force-stop "package name"
模拟按键输入
adb shell input keyevent "keycode"
"key code"
https://developer.android.com/reference/android/view/KeyEvent
电源键
26
home键
3
返回键
4
adb shell input tap 666 2222
滑动解锁
adb shell input swipe 300 1000 300 500
300 1000 300 500 表示起始点x、y坐标,结束点x、y坐标
锁屏没密码,通过滑动手势解锁
查看设备信息
机型
adb shell getprop |grep ro.config.marketing_name
型号
adb shell getprop |grep ro.hw.oemName
sn
adb shell getprop |grep ro.serialno
cpu架构
adb shell getprop |grep ro.product.cpu.abi
内存
adb shell cat /proc/meminfo
电池
adb shell dumpsys battery
屏幕分辨率
adb shell wm size
修改分辨率
adb shell wm size 480**1024
重置分辨率
adb shell wm size reset
显示屏参数
adb shell dump sys window displays
查看设备IP地址
adb shell net cfg
adb shell ifconfig | grep Mask
lte支持sim
值是3或5都可以抓debug级别日志
adb shell getprop ro.logsystem.usertype
查看内存
adb shell dumpsys meminfo com.huawei.ohos.inputmethod
内存参数说明
Uptime:表示启动到现在的时常, 不包含休眠时间,单位ms
Realtime:表示启动到现在市场,包含休眠时间,单位ms
Native Heap:指c 中malloc出来的堆空间
Dalvik Heap:指java中new出来的java堆空间
Pss Total:指占用了真实的物理内存的空间
private dirty:指私有驻留内存
Heap Size:指占用总内存(Heap 堆)
Heap Alloc:指在虚拟地址中分配了这么多空间
Heap Free:空闲内存
查看包名
adb shell "dumpsys window | grep mCurrentFocus"
其他
截图保存到电脑
adb exec-out screen -p>sc.png
>后为电脑路径
录制屏幕
adb shell screenrecord /sdcard/filename.mp4
录屏 mp4保存/sdcard
默认时长180s 停止ctrl+c
监控当前应用
adb shell am monitor
查看应用路径
adb shell pm path “com.android.mms”
monkey
运行
adb shell "monkey -p com.example.text -p com.huawei.ohos.inputmethod -v -v --throttle 300 --ignore-crashes --ignore-timeouts --monitor-native-crashes 10000000 2>/sdcard/error.txt 1>/sdcard/info.txt"
查看monkey进程
adb shell ps | grep monkey
杀死monkey进程
adb shell kill “进程号”
fastbot
adb -s YSE0221914000501 shell CLASSPATH=/sdcard/monkeyq.jar:/sdcard/framework.jar:/sdcard/fastbot-thirdpart.jar exec app_process /system/bin com.android.commands.monkey.Monkey -p com.huawei.ohos.inputmethod --agent reuseq --running-minutes 10080 --bugreport --output-directory /sdcard/test/ --throttle 700 -v -v
aapt2 dump --values strings CeliaKeyboard_1008.apk > max.valid.strings
https://github.com/bytedance/Fastbot_Android
设置输入法
set默认输入法
adb shell ime set com.iqqi.watch_imeservice/com.iqqi.watch.ImeService
enable输入法
adb shell ime enable com.iqqi.watch_imeservice/com.iqqi.watch.ImeService
disable输入法
adb shell ime disable com.touchtype.swiftkey/com.touchtype.KeyboardService
查看包名/activity
adb logcat | grep ActivityManager