Android-specific adb debug bridge command user manual

Intro

  1. Introduction to ADB
  2. ADB common command collection
  3. ADB extension commands
  4. Precautions
  5. Download the vaccination method of ADB
  6. epilogue

The full name of adb is Android Debug Bridge, which acts as a debugging bridge, that is, a bridge between Android phones and computer devices. Through adb, we can use the computer to control the Android phone to debug the Android program

The working method of adb is quite special. It uses the method of listening to ports such as Socket TCP 5554 to allow IDE to communicate with Qemu

adb is a tool in the android SDK. With this tool, you can directly operate and manage the android emulator or the real android device (such as nessus 5x mobile phone). Its main functions are:

* Run the device's shell (command line)

* Manage port mappings for emulators or devices

* Upload/download/delete files between computer and device

* Install local apk software to emulator or Android device

ADB is a client-server program, where the client is the computer you use to operate, and the server is the Android device.

adb common command collection

adb shell 连接真机/模拟器终端

adb devices  列出连接的设备(-l表示长输出)

adb -s 1234567890  当多个设备及模拟器运行时 连接指定设备

adb start-server  开启adb服务

adb kill-server  关闭adb服务,杀掉进程

adb shell reboot   重启手机

adb shell reboot fastboot  重启手机并启动fastboot模式

adb shell wipe data  擦除data,即恢复出厂设置

adb remount ,意思是将设备改为可读可写,显示remount succeeded就代表命令执行成功  有些设备并不能直接adb remount,必须要先以root身份进入,先执行adb root,在执行adb remount

adb pull 手机文件路径 电脑目标路径

adb push 电脑文件路径 手机目标路径

adb uninstall <软件名> 卸载软件且删除配置和缓存文件 

adb uninstall -k <软件名>  如果加 -k参数,  为卸载软件 但是保留配置和缓存文件

adb connect 设备ip:5555(如:192.168.1.81;5555) 安装WiFiAdb.apk  wifiadb会提供ip的端口号 即可完成 连接

adb shell pm list package 查询已安装包名列表

adb shell pm list package -s   列出系统应用

adb shell pm list package -3   列出第三方的应用

adb shell pm list package -i   列出来源

adb shell pm list package -f   列出包名和路径

adb shell pm path packagename   列出应用apk的位置

adb shell pm dump packagename   列出应用的详细信息

adb shell pm clear (apk包名) 清除应用数据与缓存

adb shell am start -n com.android.browser/.BrowserActivyty   启动指定activity

adb shell am start -S activityname  先停止应用再启动

adb shell am force-stop packagename   结束应用

adb shell am kill	                 杀指定后台进程

adb shell am kill-all	              杀所有后台进程

adb shell am force-stop Package(包名)	强杀进程

adb shell dumpsys activity | find "mF"  指定查询"mF"的activity信息

adb get-serialno  获取设备的ID和序列号

Extended command:

调试:

 bugreport [PATH]

将错误报告写入给定的PATH[default==bugreport.zip];

如果PATH是一个目录,那么错误报告将保存在该目录中。

不支持压缩错误报告输出到stdout的设备。

jdwp              列出托管jdwp传输的进程的pid

logcat            显示设备日志(logcat--有关更多信息的帮助)

网络:
 connect HOST[:PORT]   通过TCP/IP连接到设备[默认端口=5555]
 
 disconnect [HOST[:PORT]]   断开与给定TCP/IP设备的连接[默认端口=5555],或全部
 
 forward --list  列出所有socket连接
  
forward [--no-rebind] LOCAL REMOTE
  
  tcp:<port>(<local>可以是“tcp:0”以选择任何打开的端口)

  localabstract:<unix域套接字名称>

  localreserved:<unix域套接字名称>

  本地文件系统:<unix域套接字名称>

  dev:<字符设备名称>

  jdwp:<进程pid>(仅限远程)
  
   forward --remove LOCAL  删除特定的socket连接
   forward --remove-all    删除所有socket连接
 
 
备份/恢复:

  backup [-f FILE] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [PACKAGE...]
  
  将设备数据的存档写入FILE[default=backup.adb]
  
 如果提供了-all/-shared,则包列表是可选的
 
 
   -apk/-noapk:        备份/不备份.apk文件       (default -noapk)
   -obb/-noobb:        备份/不备份.obb文件       (default -noobb)
   -shared|-noshared: 备份/不备份共享存储         (default -noshared)
   -all:备份所有已安装的应用程序
   -system|-nosystem: 包括/不包括所有系统应用程序  (default -system)
 restore FILE            从指定目录恢复设备内容

adb install 扩展命令

安装[-lrtsdg]程序包

安装多个[-lrtsdpg]程序包。。。

将软件包推送到设备并安装

-l: 正向锁定应用

-r: 替换现有应用程序

-t: 允许测试包

-s: 在SD卡上安装应用程序

-d: 允许版本代码降级(仅限可调试的包)

-p: 部分应用程序安装(仅安装多个)

-g: 授予所有运行时权限

卸载[-k]程序包

从设备中删除此应用程序包

“-k”:保留数据和缓存目录

Notice:

Things to note, after the adb shell is connected to the mobile phone, it is the linux command to operate the mobile phone. The above commands are run directly. Some commands can be executed after the mobile phone is connected, omitting the adb shell.

Several ways to download adb

N5x supporting adb

https://dl-ssl.google.com/android/repository/latest_usb_driver_windows.zip

SDK Platform-Tools replace adb

https://developer.android.com/studio/releases/platform-tools?hl=zh-cn

Install under Linux

apt install adb

Conclusion:

Using ADB, you can forcibly delete the pre-installed software in the system, you can also backup and restore the software in the mobile phone, you can also forcefully stop the specified running Android program, you can also start the APP in debug mode to debug the app, ADB dominates in the app reverse. missing position.

Guess you like

Origin blog.csdn.net/qq_41100456/article/details/130211788