AndroidTV开发中常用ADB命令(持续更新)

I.指定设备

同时连接了多个机顶盒时,向指定机顶盒传递指令
adb -s <IP>
例如:
adb -s 192.168.0.100 shell am start -n a.b.c/a.b.c.activity

II.启动、关闭APP

启动

adb shell am start <-a>/<-n>

通过action启动-a

例:adb shell am start -a xxx.xxx.xxx

通过包名类名启动-n

包名:a.b.c
类名:a.b.c.MainActivity
例:adb shell am start a.b.c/.MainActivity

如果需要携带intent参数:
adb shell am start -n a.b.c/.MainActivity --es <key1> <value1> --es <key2> <value2>

关闭

adb shell am force-stop <包名>

III.截屏

(建议使用采集卡,直接将画面输出到PC端方便截图等操作)
(测试时无效)adb shell screencap " -p | sed 's/\r$//'" > c:\Users\user\Desktop\screen.png
(测试时无效)adb shell screencap " -p | perl -pe 's/\x0D\x0A/\x0A/g' "> c:\Users\user\Desktop\screen.png
测试时有效:
1.先保存到机顶盒:
adb shell screencap -p /sdcard/screen.png
2.再保存到PC端:
adb pull /sdcard/screen.png c:\Users\user\Desktop\screen.png

IV.录屏

(建议使用采集卡,直接将画面输出到PC端方便截图等操作)
视频文件保存到机顶盒,步骤类似于III.截屏
adb shell screenrecord /sdcard/demo.mp4
限制录制时间:adb shell screenrecord --time-limit 10 /sdcard/demo.mp4(限制时间为10秒,不限制为180秒)
限制分辨率:adb shell screenrecord --size 1280x720 /sdcard/demo.mp4(分辨率为1280x720,如果不指定默认使用手机的分辨率)
限制比特率:adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4(指定视频的比特率为6Mbps,如果不指定,默认为4Mbps)

V.打印日志

保存日志文件,文件保存到adb目录下,ctrl+c停止输出日志并保存文件
adb shell logcat ->log.txt
如果需要使用过滤器:
1.先进入shell模式:
adb shell
2.再使用logcat命令,并添加grep命令
logcat | grep <过滤条件>

VI.系统相关

A.查看进程

adb shell ps(可查看PID)

B.内存占用

adb shell dumpsys meminfo <pid>

C.CPU占用率

adb shell top

D.清理APP缓存

adb shell pm clear <包名>

E.Android系统版本

adb shell getprop
[ro.build.version.release] - 平台版本
[ro.build.version.sdk] - SDK版本

F.获取ROOT权限

adb root
adb remount

G.文件操作

adb push <文件路径> <推送目的路径> 推送文件
adb pull 拉取文件

H.往/system目录下推送文件

在获取ROOT权限以后还需要设置system目录可读写
adb shell
mount -o remount,rw /system

I.查看各分区大小

adb shell df
根据总空间和已用空间可快速定位挂载U盘的路径。

J.发送广播

adb shell am broadcast <-a> <-c> <-e>
-a --ACTION
-c --CATEGORY
-e --EXTRA_KEY

VII.APK相关

A.查询APP信息

adb shell dumpsys <包名>

B.查看APK文件信息

在SDK文件夹下的build-tools文件夹中找到aapt工具
aapt dump badging <APK文件>
可以获得package:namelaunchable-activity用于ADB启动APP

C.获取已安装的APK

如果不知道包名:adb shell pm list package查看已安装APP的包名
adb shell pm path <包名> 根据包名查询APK位置
adb pull <地址> 获取APK

D.查看签名

解压缩APK文件,在META-INF文件夹下有个.RSA后缀的文件
keytool -printcert -file <文件名>.RSA

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值