当前位置:首页 > IT技术

adb常用命令

时间:2019-08-20 17:14:18来源:IT技术作者:SEO探针小编阅读:76次「手机版」
 

adb 命令

https://blog.csdn.net/weixin_40811410/article/details/82015773

一、adb命令电脑上操作的命令)

ADB常用命令:

1. 查看设备: 查看当前连接的设备,

adb  devices

2. 安装软件:将指定的apk文件安装到设备上

adb  install <apk文件路径>

如: adb install com.sina.weibo    

参数“-r”,它是更新安装的意思,

参数 -s ,安装到sdcard.

3. 卸载软件

adb  uninstall <包名>

如: adb uninstall com.sina.weibo    

如果加 -k 参数,为卸载软件但是保留配置和缓存文件.

4. 登录设备shell

登录默认设备(当只有一台设备时)

adb  shell 

adb shell <command命令>

如:    adb  shell cat /proc/kmsg 

登录设备的shell,后面加<command命令>将是直接运行设备命令, 相当于执行远程命令

登录指定设备(当存在一台设备时)

C:\Users\admin>adb devices

输出:List of devices attached

03ba45d84381a8d3        device

04e9a66c25234a67        device

FEJNOBD6IND6HU5H        device

C:\Users\admin>adb -s FEJNOBD6IND6HU5H shell

输出(登录成功):

root@4G+:/ #

5. 从电脑上发送文件到设备 :可以把本机电脑上的文件或者文件夹复制到设备(手机)

adb push <本地路径> <远程路径>

如: adb push /local/build.prop  /system/build.prop

6. 从设备上下载文件到电脑:可以把设备(手机)上的文件或者文件夹复制到本机电脑

adb  pull <远程路径> <本地路径>

如: adb  pull /system/build.prop  /local/

7. 同步更新

adb sync [ <directory> ]

如: adb sync /data/

如果不指定目录,将同时更新 /data 和 /system/

8. 显示帮助信息

adb  help

9. 重新挂载

adb  remount

重新挂载系统 分区 用于读写

10. 启动和关闭server

adb start-server             - ensure that there is a server running

adb kill-server              - kill the server if it is running

11. 重启设备

adb reboot [bootloader|recovery]      - reboots the device, optionally into the bootloader or recovery program

12. 查看Log

[adb] logcat [<option>] ... [<filter-spec>] ..

-b 加载一个可使用的日志缓冲区供查看,比如event 和radio . 默认值是main 。具体查看Viewing Alternative Log Buffers.

-c 清楚屏幕上的日志.

-d 输出日志到屏幕上.

-f 指定输出日志信息的 ,默认是stdout .

-g 输出指定的日志缓冲区,输出后退出.

-n 设置日志的最大数目 .,默认值是4,需要和 -r 选项一起使用。

-r 每 时输出日志,默认值为16,需要和-f 选项一起使用.

-s 设置默认的过滤级别为silent.

-v 设置日志输入格式,默认的是brief 格式

where <tag> is a log component tag (or * for all) and priority is:

V    Verbose

D    Debug

I    Info

W    Warn

E    ERROR

F    Fatal

S    Silent (supress all output)

'*' means '*:d' and <tag> by itself means <tag>:v

13、查看bug报告:

adb bugreport

二、adb shell命令(手机设备上操作的命令)

常用adb shell命令:

1. 按键事件

input text <string>   input a string to device

input keyevent <event_code>   send a Key Event to device

如: adb shell input keyevent 26      (PowerKey)

2. am命令

命令    作用    例子

am start [options]    启动Activity    am start -n com.eg.Android.AlipayGphone/com.alipay.mobile.payee.ui.PayeeQRSetMoneyActivity

am startservice    启动Service    am startservice com.miui.powerkeeper

am stopservice    停止Service    

am broadcast    发送广播    

am kill    kill指定进程    

am force-stop    强制停止某进程    

am hang    系统hang住    

am restart    重启手机    

am dumpheap    将进程pid的堆信息输出到file    

am start [options] 的options参数

(1)am启动activity:

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

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

(2)-a :am start -a -d

am start -a android.intent.action.DIAL -d tel:10010 //编辑电话(在拨号盘界面按下电话号码,但是不拨打)

am start -a android.intent.action.VIEW -d https://www.baidu.com  //打开某个网址

am start -a android.intent.action.MUSIC_PLAYER  //打开音乐播放器

(3)-d <DATA_URI>:启动时,要传入的URI

am start -d content://contacts/people/1

(4)-n :直接启动一个组件

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

(5)-t <MIME_TYPE>: 指定Intent MIME Type

am start -t image/png

(6)-c [-c ] …]:指定Intent category

am start -c android.intent.category.APP_CONTACTS

3. pm 命令

命令    作用

pm list packages    列举app包信息

pm install [options]    安装应用

pm uninstall [options]    卸载应用

pm hide    隐藏应用

pm unhide    显示应用

pm get-install-location    获取安装位置

pm clear    清空App数据

pm force-dex-opt    dexmanbetx体育

pm dump    dump信息

pm install [options] 的options参数

-r: 覆盖安装已存在Apk,并保持原有数据;

-d: 运行安装低版本Apk;

-t: 运行安装测试Apk

-i <installer_package_name style=“box-sizing: border-box;”>: 指定Apk的安装器;</installer_package_name>

-s: 安装apk到共享快存储,比如sdcard;

-f: 安装apk到内部系统内存

-l: 安装过程,持有转发锁

-g: 准许Apk manifest中的所有权限;

4. dumpsys命令

dumpsys activit

dumpsys activity intents

dumpsys activity broadcasts

dumpsys activity providers

dumpsys activity services

dumpsys activity activities

dumpsys activity processes

获取当前activity信息

adb shell dumpsys activity top 

dumpsys window

dumpsys window windows

dumpsys window tokens

dumpsys window sessions

dumpsys window policy

dumpsys window input

获取当前activity名称

如:adb shell dumpsys window windows | findstr Current 

--------------------- 

作者:YSoul. 

来源:CSDN 

原文:https://blog.csdn.net/weixin_40811410/article/details/82015773 

相关阅读

玩转ADB命令(ADB命令使用大全)

此文章内容整合自网络,欢迎转载。我相信做Android开发的朋友都用过ADB命令,但是也只是限于安装应用push文件和设备重启相关,根深的也

ADB 学习(2):adb install 命令

一、前言 作为一个测试人员,对于手机的应用软件肯定少不了安装到指定的手机设备中,所以 adb install 这个命令是必不可少的。 二、

windows配置安装adb的一些方法

adb是Android的一个很重要的调试工具,熟练掌握后可实现很多功能,比如有些手机的解锁、ROOT就会用到adb工具。可很多朋友都说不会安

adb bugreport 原理

0.文章学习 https://www.2cto.com/kf/201607/528696.html 1.使用场景 使用 adb bugreport 可以导出功耗分析所需文件,然后通过

最新adb下载地址

以下是adb工具包最新Google官方版下载地址: ADB和Fastboot for Windows https://dl.google.com/android/repository/platform-tool

分享到:

栏目导航

推荐阅读

热门阅读