[初识 ADB ]-安卓调试桥

##################################################

目录

ADB 简介与获取安装

ADB 调试桥简介

获取 ADB

Windows 安装 ADB

命令行永久配置 adb 环境变量

一些简单的 ADB 命令

本站资源

好人哦


##################################################

ADB 简介与获取安装

——————————

ADB 调试桥简介

        adb 的全称为 Android Debug Bridge/安卓调试桥

        Android 调试桥 adb 是一种功能多样的命令行工具 可以让你与设备进行通信
        adb 命令可以用于执行各种设备操作 例如安装和调试应用 并提供对 UNIX 终端的访问权限

        她是一种 客户端-服务器 程序
        包括以下三个组件:

客户机    用于发送命令 客户端在开发机器上运行 你可以通过发出 adb 命令从命令行终端调用客户端
守护进程 adbd    用于在设备上运行命令 守护程序在每个设备上作为后台进程运行
服务器    用于管理客户端与守护程序之间的通信 服务器在开发机器上作为后台进程运行

        adb 包含在 Android SDK 平台工具软件包中 你可以使用 SDK 管理器下载此软件包
        该管理器会将其安装在 android_sdb/platform-tools/ 下用

        这个工具可以直接操作管理 android 模拟器或者真实的 android 设备

        主要功能有:

运行设备的 shell 命令行
管理模拟器或设备的端口映射
计算机和设备之间 上传/下载 文件
将本地 apk 软件安装至模拟器或 android 设备

——————————

获取 ADB

        或者如果你需要独立的 Android SDK 平台工具请单独下载 一般我们都是选择单独安装这个:

SDK Platform Tools 版本说明  |  Android 开发者  |  Android DevelopersAndroid SDK Platform-Tools 是 Android SDK 的一个组件。https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cnicon-default.png?t=M666https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cn        下载 Windows 的就行:

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

        借助 adb 工具我们可以管理设备或手机模拟器的状态 还可以进行很多手机操作 如

安装软件

系统升级

运行 shell 命令

        等等

        其实简而言说 adb 就是连接 Android 手机与 PC 端的桥梁 可以让用户在电脑上对手机进行全面的操作

        通过 adb 我们还可以在 Eclipse 中方通过 DDMS 来调试 Android 程序

        说白了就是 debug 工具

        adb 的工作方式比较特殊 采用监听 Socket TCP 5554 等端口的方式让 IDE 和 Qemu 通讯

        默认情况下 adb 会 daemon 相关的网络端口 所以当我们运行 Eclipse 时 adb 进程就会自动运行

——————————

Windows 安装 ADB

        解压压缩包 得到目录 platform-tools

        重命名为 adb 剪切到 C 盘根目录下:

adb

        这就算安装完毕了!

        打开 cmd 窗口:

cmd

        可以使用命令:

>cd /adb

>adb devices    /* 查看设备列表 */
List of devices attached


>

adb devices

        只是这些文件就非常强大了:

adb

——————————

命令行永久配置 adb 环境变量

        以管理员身份运行 cmd

管理员身份运行 cmd

         输入如下命令添加 adb 路径 我这边 adb 目录直接放 c 盘根目录下了:

setx "path" "%path%;C:\adb;"

        示例:

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

C:\Windows\system32>set Path    /* 查看系统环境变量 */
Path=C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86
)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\P
rogram Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System
32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel
\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\P
rogram Files\qemu;D:\Java\jdk1.7.0_79\bin;D:\Java\jdk1.7.0_79\jre\bin;C:\Program
 Files\dotnet\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Fil
es (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQ
L Server\110\Tools\Binn\;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\User
s\byme\.dotnet\tools;C:\Users\byme\AppData\Local\Programs\Microsoft VS Code\bin;
D:\Tencent\QQGameTempest\Hall.57807\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

C:\Windows\system32>setx "path" "%path%;C:\adb;"    /* 添加路径 */

成功: 指定的值已得到保存。

C:\Windows\system32>

        之后在任何目录都可以使用 adb 了:

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

C:\Users\byme>adb
Android Debug Bridge version 1.0.41
Version 33.0.2-8557947
Installed as C:\adb\adb.exe

global options:
 -a                       listen on all network interfaces, not just localhost
 -d                       use USB device (error if multiple devices connected)
 -e                       use TCP/IP device (error if multiple TCP/IP devices av
ailable)
 -s SERIAL                use device with given serial (overrides $ANDROID_SERIA
L)
 -t ID                    use device with given transport id
 -H                       name of adb server host [default=localhost]
 -P                       port of adb server [default=5037]
 -L SOCKET                listen on given socket for adb server [default=tcp:loc
alhost:5037]
 --one-device SERIAL|USB  only allowed with 'start-server' or 'server nodaemon',
 server will only connect to one USB device, specified by a serial number or USB
 device address.
 --exit-on-write-error    exit if stdout is closed

general commands:
 devices [-l]             list connected devices (-l for long output)
 help                     show this help message
 version                  show version num

networking:
 connect HOST[:PORT]      connect to a device via TCP/IP [default port=5555]
 disconnect [HOST[:PORT]]
     disconnect from given TCP/IP device [default port=5555], or all
 pair HOST[:PORT] [PAIRING CODE]
     pair with a device for secure TCP/IP communication
 forward --list           list all forward socket connections
 forward [--no-rebind] LOCAL REMOTE
     forward socket connection using:
       tcp:<port> (<local> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
       jdwp:<process pid> (remote only)
       vsock:<CID>:<port> (remote only)
       acceptfd:<fd> (listen only)
 forward --remove LOCAL   remove specific forward socket connection
 forward --remove-all     remove all forward socket connections
 ppp TTY [PARAMETER...]   run PPP over USB
 reverse --list           list all reverse socket connections from device
 reverse [--no-rebind] REMOTE LOCAL
     reverse socket connection using:
       tcp:<port> (<remote> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
 reverse --remove REMOTE  remove specific reverse socket connection
 reverse --remove-all     remove all reverse socket connections from device
 mdns check               check if mdns discovery is available
 mdns services            list all discovered services

file transfer:
 push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE
     copy local files/directories to device
     --sync: only push files that are newer on the host than the device
     -n: dry run: push files to device without storing to the filesystem
     -z: enable compression with a specified algorithm (any/none/brotli/lz4/zstd
)
     -Z: disable compression
 pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL
     copy files/dirs from device
     -a: preserve file timestamp and mode
     -z: enable compression with a specified algorithm (any/none/brotli/lz4/zstd
)
     -Z: disable compression
 sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendo
r]
     sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
     -n: dry run: push files to device without storing to the filesystem
     -l: list files that would be copied, but don't copy them
     -z: enable compression with a specified algorithm (any/none/brotli/lz4/zstd
)
     -Z: disable compression

shell:
 shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
     run remote shell command (interactive shell if no command given)
     -e: choose escape character, or "none"; default '~'
     -n: don't read from stdin
     -T: disable pty allocation
     -t: allocate a pty if on a tty (-tt: force pty allocation)
     -x: disable remote exit codes and stdout/stderr separation
 emu COMMAND              run emulator console command

app installation (see also `adb shell cmd package help`):
 install [-lrtsdg] [--instant] PACKAGE
     push a single package to the device and install it
 install-multiple [-lrtsdpg] [--instant] PACKAGE...
     push multiple APKs to the device for a single package and install them
 install-multi-package [-lrtsdpg] [--instant] PACKAGE...
     push one or more packages to the device and install them atomically
     -r: replace existing application
     -t: allow test packages
     -d: allow version code downgrade (debuggable packages only)
     -p: partial application install (install-multiple only)
     -g: grant all runtime permissions
     --abi ABI: override platform's default ABI
     --instant: cause the app to be installed as an ephemeral install app
     --no-streaming: always push APK to device and invoke Package Manager as sep
arate steps
     --streaming: force streaming APK directly into Package Manager
     --fastdeploy: use fast deploy
     --no-fastdeploy: prevent use of fast deploy
     --force-agent: force update of deployment agent when using fast deploy
     --date-check-agent: update deployment agent when local version is newer and
 using fast deploy
     --version-check-agent: update deployment agent when local version has diffe
rent version code and using fast deploy
     (See also `adb shell pm help` for more options.)
 uninstall [-k] PACKAGE
     remove this app package from the device
     '-k': keep the data and cache directories

debugging:
 bugreport [PATH]
     write bugreport to given PATH [default=bugreport.zip];
     if PATH is a directory, the bug report is saved in that directory.
     devices that don't support zipped bug reports output to stdout.
 jdwp                     list pids of processes hosting a JDWP transport
 logcat                   show device log (logcat --help for more)

security:
 disable-verity           disable dm-verity checking on userdebug builds
 enable-verity            re-enable dm-verity checking on userdebug builds
 keygen FILE
     generate adb public/private key; private key stored in FILE,

scripting:
 wait-for[-TRANSPORT]-STATE...
     wait for device to be in a given state
     STATE: device, recovery, rescue, sideload, bootloader, or disconnect
     TRANSPORT: usb, local, or any [default=any]
 get-state                print offline | bootloader | device
 get-serialno             print <serial-number>
 get-devpath              print <device-path>
 remount [-R]
      remount partitions read-write. if a reboot is required, -R will
      will automatically reboot the device.
 reboot [bootloader|recovery|sideload|sideload-auto-reboot]
     reboot the device; defaults to booting system image but
     supports bootloader and recovery too. sideload reboots
     into recovery and automatically starts sideload mode,
     sideload-auto-reboot is the same but reboots after sideloading.
 sideload OTAPACKAGE      sideload the given full OTA package
 root                     restart adbd with root permissions
 unroot                   restart adbd without root permissions
 usb                      restart adbd listening on USB
 tcpip PORT               restart adbd listening on TCP on PORT

internal debugging:
 start-server             ensure that there is a server running
 kill-server              kill the server if it is running
 reconnect                kick connection from host side to force reconnect
 reconnect device         kick connection from device side to force reconnect
 reconnect offline        reset offline/unauthorized devices to force reconnect

usb:
 attach                   attach a detached USB device
 detach                   detach from a USB device to allow use by other process
es
environment variables:
 $ADB_TRACE
     comma-separated list of debug info to log:
     all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
 $ADB_VENDOR_KEYS         colon-separated list of keys (files or directories)
 $ANDROID_SERIAL          serial number to connect to (see -s)
 $ANDROID_LOG_TAGS        tags to be used by logcat (see logcat --help)
 $ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)
 $ADB_MDNS_AUTO_CONNECT   comma-separated list of mdns services to allow auto-co
nnect (default adb-tls-connect)

C:\Users\byme>

——————————

一些简单的 ADB 命令

        用 adb 工具的前提是在手机上打开 usb 调试,然后通过数据线连接电脑

        然后就可以在电脑上使用命令模式来操作手机 例如

重启

进入 recovery

进入 fastboot

推送文件

        功能等

        值得强调一点的是在 recovery 模式下也可以使用 adb 命令来控制手机

        所以如果是刷机失败的话在一定的时候还能用到 adb 工具

    简单 ADB 命令:
adb devices    /* 显示当前连接的设备 */
adb install *.apk    /* 安装 apk 文件 这个 apk 文件必须和 adb 同目录 */
adb install -s *.apk    /* 安装 apk 文件到 sd 卡 这个 apk 文件必须和 adb 同目录 */
adb push 电脑文件位置 手机位置    /* 复制文件到手机指定位置 例如 adb push D:\A.apk /sdcard */
adb pull 手机文件位置 电脑位置    /* 复制文件到电脑指定位置 例如 adb pull sdcard/A.apk D:\ */
adb reboot    /* 重启设备 */
adb reboot recovery    /* 重启设备到 recovery 模式 */
adb reboot bootloader    /* 重启到 bootloader 模式 */

        其她的命令都跟 Linux 差不多啦!

##################################################

本站资源

——————————

好人哦

ADB安卓调试桥密码ranchui-Java文档类资源-CSDN下载老密码ranchui可以连接机顶盒还有安卓手机懂得都知道这是稀缺资源!!!更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/m0_67268286/85486697

pan.baidu.com s 1ZkIbykC2Le104Yb2oJBeoQ 
1302
ranchui

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

燃吹

呜呜呜没钱钱吃饭了……

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值