adb 使用
前言
adb,全称 android debug bridge,是 android 的命令行调试工具,可以完成多种功能,如跟踪系统日志,上传下载文件,安装应用等。
准备连接
firefly-rk3288/firefly-rk3288-reload 默认是打开usb调试选项。如果需要在关闭或打开usb调试选项,可以 在设置->关于设备->版本号(点击7次后),然后返回到上一层,可以看到开发者选项,然后点击进入进行设置, 使用micro usb otg 线连接设备和主机进行连接。
windows下的 adb 安装
首先参照安装 rk usb 驱动一节安装好驱动。 然后到 http://adbshell.com/download/download-adb-for-windows.html 下载 adb.zip,解压到 c:\adb 以方便调用。 打开命令行窗口,输入:
cd c:\adb adb shell
如果一切正常,就可以进入adb shell,在设备上面运行命令。
ubuntu 下的 adb 安装
安装 adb 工具:
sudo apt-get install android-tools-adb
加入设备标识:
mkdir -p ~/.android vi ~/.android/adb_usb.ini # 添加以下一行 0x2207
加入 udev 规则:
sudo vi /etc/udev/rules.d/51-android.rules # 添加以下一行: subsystem==usb, attr{idvendor}==2207, mode=0666
重新插拔 usb 线,或运行以下命令,让 udev 规则生效:
sudo udevadm control --reload-rules sudo udevadm trigger
重新启动 adb 服务器
sudo adb kill-server adb start-server
常用 adb 命令
连接管理
列出所有连接设备及其序列号
adb devices
如果有多个连接设备,则需要使用序列号来区分:
export android_serial= adb shell ls
可以通过网络来连接 adb:
# 让设备端的 adbd 重启,并在 tcp 端口 5555 处监听 adb tcpip 5555 # 此时可以断开 usb 连接 # 远程连接设备,设备的 ip 地址是 192.168.1.100 adb connect 192.168.1.100:5555 # 断开连接 adb disconnect 192.168.1.100:5555
调试
获取系统日志 adb logcat
用法
adb logcat [选项] [应用标签]
示例
# 查看全部日志 adb logcat # 仅查看部分日志 adb logcat -s wifistatemachine statemachine
运行命令 adb shell
adb bugreport 用于错误报告,里面包含大量有用的信息
adb bugreport # 保存到本地,方便用编辑器查看 adb bugreport >bugreport.txt
应用管理
安装应用 adb install
用法:
adb install [选项] 应用包.apk 选项包括: -l forward-lock -r 重新安装应用,保留原先数据 -s 安装到 sd 卡上,而不是内部存储
示例:
# 安装 facebook.apk adb install facebook.apk # 升级 twitter.apk adb install -r twitter.apk
如果安装成功,工具会返回成功提示 “success”;失败的话,一般是以下几种情况
install_failed_already_exists: 此时需要用 -r 参数来重新安装。
install_failed_signature_error: 应用的签名不一致,可能是发布版和调试版签名不同所致。如果确认 apk 文件签名正常,可以用 adb uninstall 命令先卸载旧的应用,然后再安装。
install_failed_insufficient_storage: 存储空间不足,需要检查设备存储情况。
卸载应用 adb uninstall
用法:
adb uninstall 应用包名称
示例:
adb uninstall com.android.chrome 应用包名称可以用以下命令列出: adb shell pm list packages -f 运行结果是: package:/system/app/bluetooth.apk=com.android.bluetooth 前面是 apk 文件,后面则是对应的包名称。
命令行帮助信息 adb help
android debug bridge version 1.0.31 -a - directs adb to listen on all interfaces for a connection -d - directs command to the only connected usb device returns an error if more than one usb device is present. -e - directs command to the only running emulator. returns an error if more than one emulator is running. -s - directs command to the device or emulator with the given serial number or qualifier. overrides android_serial environment variable. -p - simple product name like 'sooner', or a relative/absolute path to a product out directory like 'out/target/product/sooner'. if -p is not specified, the android_product_out environment variable is used, which must be an absolute path. -h - name of adb server host (default: localhost) -p - port of adb server (default: 5037) devices [-l] - list all connected devices ('-l' will also list device qualifiers) connect [:] - connect to a device via tcp/ip port 5555 is used by default if no port number is specified. disconnect [[:]] - disconnect from a tcp/ip device. port 5555 is used by default if no port number is specified. using this command with no additional arguments will disconnect from all connected tcp/ip devices. device commands: adb push [-p] - copy file/dir to device ('-p' to display the transfer progress) adb pull [-p] [-a] [] - copy file/dir from device ('-p' to display the transfer progress) ('-a' means copy timestamp and mode) adb sync [ ] - copy host->device only if changed (-l means list but don't copy) (see 'adb help all') adb shell - run remote shell interactively adb shell - run remote shell command adb emu - run emulator console command adb logcat [ ] - view device log adb forward --list - list all forward socket connections. the format is a list of lines with the following format: \n adb forward - forward socket connections forward specs are one of: tcp: localabstract: localreserved: localfilesystem: dev: jdwp: (remote only) adb forward --no-rebind - same as 'adb forward ' but fails if is already forwarded adb forward --remove - remove a specific forward socket connection adb forward --remove-all - remove all forward socket connections adb jdwp - list pids of processes hosting a jdwp transport adb install [-l] [-r] [-d] [-s] [--algo --key --iv ] - push this package file to the device and install it ('-l' means forward-lock the app) ('-r' means reinstall the app, keeping its data) ('-d' means allow version code downgrade) ('-s' means install on sd card instead of internal storage) ('--algo', '--key', and '--iv' mean the file is encrypted already) adb uninstall [-k] - remove this app package from the device ('-k' means keep the data and cache directories) adb bugreport - return all information from the device that should be included in a bug report. adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [] - write an archive of the device's data to . if no -f option is supplied then the data is written to backup.ab in the current directory. (-apk|-noapk enable/disable backup of the .apks themselves in the archive; the default is noapk.) (-obb|-noobb enable/disable backup of any installed apk expansion (aka .obb) files associated with each application; the default is noobb.) (-shared|-noshared enable/disable backup of the device's shared storage / sd card contents; the default is noshared.) (-all means to back up all installed applications) (-system|-nosystem toggles whether -all automatically includes system applications; the default is to include system apps) ( is the list of applications to be backed up. if the -all or -shared flags are passed, then the package list is optional. applications explicitly given on the command line will be included even if -nosystem would ordinarily cause them to be omitted.) adb restore - restore device contents from the backup archive adb help - show this help message adb version - show version num scripting: adb wait-for-device - block until device is online adb start-server - ensure that there is a server running adb kill-server - kill the server if it is running adb get-state - prints: offline | bootloader | device adb get-serialno - prints: adb get-devpath - prints: adb status-window - continuously print device status for a specified device adb remount - remounts the /system partition on the device read-write adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program adb reboot-bootloader - reboots the device into the bootloader adb root - restarts the adbd daemon with root permissions adb usb - restarts the adbd daemon listening on usb adb tcpip - restarts the adbd daemon listening on tcp on the specified port networking: adb ppp [parameters] - run ppp over usb. note: you should not automatically start a ppp connection. refers to the tty for ppp stream. eg. dev:/dev/omap_csmi_tty1 [parameters] - eg. defaultroute debug dump local notty usepeerdns adb sync notes: adb sync [ ] can be interpreted in several ways: - if is not specified, both /system and /data partitions will be updated. - if it is system or data, only the corresponding partition is updated. environmental variables: adb_trace - print debug information. a comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp android_serial - the serial number to connect to. -s takes priority over this if given. android_log_tags - when used with the logcat option, only these debug tags are printed.
关于智能黑板的性能分析和介绍
步进电机的构成主要有哪些?
液晶显示器不开机的故障维修
集成稳压器/三端稳压应用电路?_集成稳压器分类_集成稳压器符号和外形图
什么情况下运放才能用虚短和虚断的概念
Firefly-RK3288ADB主板介绍
2023百度云智大会看点:李彦宏表示卷大模型没有意义 不如卷应用
OPPOReno新机细节公布 初期一共有四种配色后续考虑会出其他颜色版本
快速恢复整流二极管的特点
HP4263B型LCR测量仪检测电感时的短路校正方法
微机消谐装置所消除的谐振过电压可分为哪几种
调光台灯原理电路图
华为、中兴大举进军智能手机市场
汽车芯片格局,汽车半导体行业近年兼并收购事件
芯片缺货导致SSD价格全线上涨
5G+互联网缓解制造业长期痛点
高度“智慧”护航先进技术,王力重新定义“智慧门”
锤子T3曝光:外观惊艳,设计独特,老罗这次不卖情怀了!
伺服电机控制高压大流量双泵液压动力系统
深度好文:看懂3D晶体管的奥秘