5.1 物联网RK3399项目开发实录-Android开发之ADB使用(wulianjishu666)

物联网项目开发实例:

链接:https://pan.baidu.com/s/11VQMhHfIL9mZhNlls4wmjw?pwd=0gfa

1. ADB 使用

1.1. 前言

ADB,全称 Android Debug Bridge,是 Android 的命令行调试工具,可以完成多种功能,如跟踪系统日志,上传下载文件,安装应用等。

1.2. 准备连接

一般情况下adb是默认开启的,如果没有开启请执行以下步骤:

  • AIO-3399J用双公头USB数据线连接设备和主机;

  • 根据当前Android版本勾选对应路径下的Connect to PC

    • Android7.1、Android8.1 选择 Setting -> USB,然后勾选 Connect to PC

    • Android10.0 选择 Setting -> Connected devices 然后勾选 Connect to PC

  • 基于你的系统安装 adb 驱动和命令。

当设备端状态栏提示 USB debugging connected 时,便可进行调试:

adb devices
adb shell

_images/otg_interface.jpg

1.3. 网络 ADB

  • 设置 -> 开发者选项 -> 网络 ADB 调试

查看开发板 IP 地址,PC 端通过网络访问:

adb connect + IP
adb shell

1.4. Windows下的 ADB 安装

首先参照安装 RK USB 驱动一节安装好驱动。

然后到 Firefly | 让科技更简单,让生活更智能 下载 adb.zip,解压到 C:\adb 以方便调用。

打开命令行窗口,输入:

cd C:\adb
adb shell

如果一切正常,就可以进入 adb shell,在设备上面运行命令。

1.5. 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

1.6. 常用 ADB 命令

1.6.1. 连接管理

列出所有连接设备及其序列号:

adb devices

如果有多个连接设备,则需要使用序列号来区分:

export ANDROID_SERIAL=<设备序列号>
adb shell ls

多设备下连接指定设备

adb -s 序列号 shell

可以通过网络来连接 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

1.7. 调试

1.7.1. 获取系统日志 adb logcat

  • 用法

adb logcat [选项] [应用标签]
  • 示例

# 查看全部日志
adb logcat
# 仅查看部分日志
adb logcat -s WifiStateMachine StateMachine

1.7.2. 运行命令 adb shell

1.7.2.1. 获取详细运行信息 adb bugreport

adb bugreport 用于错误报告,里面包含大量有用的信息。

  • 示例

adb bugreport
# 保存到本地,方便用编辑器查看
adb bugreport >bugreport.txt

1.7.3. root 权限

如果 TARGET_BUILD_VARIANT 使用的是 userdebug 模式,要获得 root 权限,需要先运行:

adb root

让 ADB 的设备端切换到 root 权限模式,这样 adb remount 等需要 root 权限的命令才会成功。

1.8. 应用管理

1.8.1. 安装应用 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: 存储空间不足,需要检查设备存储情况。

1.8.2. 卸载应用 adb uninstall

  • 用法:

adb uninstall 应用包名称
  • 示例:

adb uninstall com.android.chrome

应用包名称可以用以下命令列出:

adb shell pm list packages -f

运行结果是:

package:/system/app/Bluetooth.apk=com.android.bluetooth

前面是 apk 文件,后面则是对应的包名称。

1.8.3. 命令行帮助信息 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 <specific device>          - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
 -p <product name or path>     - 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 <host>[:<port>]       - connect to a device via TCP/IP
                                 Port 5555 is used by default if no port number is specified.
 disconnect [<host>[:<port>]]  - 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] <local> <remote>
                               - copy file/dir to device
                                 ('-p' to display the transfer progress)
  adb pull [-p] [-a] <remote> [<local>]
                               - copy file/dir from device
                                 ('-p' to display the transfer progress)
                                 ('-a' means copy timestamp and mode)
  adb sync [ <directory> ]     - 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 <command>          - run remote shell command
  adb emu <command>            - run emulator console command
  adb logcat [ <filter-spec> ] - View device log
  adb forward --list           - list all forward socket connections.
                                 the format is a list of lines with the following format:
                                    <serial> " " <local> " " <remote> "\n"
  adb forward <local> <remote> - forward socket connections
                                 forward specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)
  adb forward --no-rebind <local> <remote>
                               - same as 'adb forward <local> <remote>' but fails
                                 if <local> is already forwarded
  adb forward --remove <local> - 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 <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file>
                               - 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] <package> - 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 <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
                               - write an archive of the device's data to <file>.
                                 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)
                                 (<packages...> 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 <file>           - restore device contents from the <file> 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: <serial-number>
  adb get-devpath              - prints: <device-path>
  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 <port>             - restarts the adbd daemon listening on TCP on the specified port
networking:
  adb ppp <tty> [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PPP connection.
 <tty> 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 [ <directory> ]
  <localdir> can be interpreted in several ways:

  - If <directory> 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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/493208.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

flutter Got socket error trying to find package nested at

flutter Got socket error trying to find package nested at xxx 报错信息&#xff1a;“Got socket error trying to find package nested at” 通常出现在Flutter尝试从pub.dev获取依赖包时&#xff0c;由于网络问题导致无法连接到pub.dev或者无法正确解析包的路径。 例如&…

LIS、LCS算法模型

文章目录 1.LCS算法模型2.LIS算法模型 1.LCS算法模型 LCS问题就是给定两个序列A和B&#xff0c;求他们最长的公共子序列。 在求解时&#xff0c;我们会设dp[i][j]表示为A[1 ~ i]序列和B[1 ~ j]序列中&#xff08;不规定结尾&#xff09;的最长子序列的长度。 if(a[i]b[i]) dp…

【算法刷题 | 二叉树 04】3.27(翻转二叉树、对称二叉树、完全二叉树的节点个数、平衡二叉树、完全二叉树的所有路径)

文章目录 6.翻转二叉树6.1问题6.2解法一&#xff1a;递归6.2.1递归思路&#xff08;1&#xff09;确定递归函数的参数和返回值&#xff08;2&#xff09;确定终止条件&#xff08;3&#xff09;确定单层递归的逻辑 6.2.2全部代码 6.3解法二&#xff1a;层序遍历 7.对称二叉树7.…

SQLynx发布3.0.0版本:带来更流畅便捷的SQL开发体验

作为新一代的一站式数据库管理开发工具&#xff0c; SQLynx自发布上线以来&#xff0c;一直受到广大用户的好评与鼓励。 为了给用户提供更高效、更便捷、更可靠的数据库管理开发体验&#xff0c;SQLynx今日正式发布3.0.0版本&#xff0c;同步在麦聪软件官网上线&#xff0c;全…

k8s入门到实战(十四)—— Helm详细介绍及使用

Helm 使用 Helm 是一个 k8s 应用的包管理工具&#xff0c;类似于 Ubuntu 的 APT 和 CentOS 中的 YUM。 Helm 使用 chart 来封装 k8s 应用的 yaml 文件&#xff0c;我们只需要设置自己的参数&#xff0c;就可以实现自动化的快速部署应用。 Helm 通过打包的方式&#xff0c;支…

常用的AD规则设置

目录 规则编辑器&#xff1a; 间距规则&#xff1a; 线宽规则&#xff1a; 过孔规则&#xff1a; 铺铜设置&#xff1a; 生成制造过孔&#xff1a; 过孔之间间距&#xff1a; 最小阻焊层间距&#xff1a; 丝印到阻焊的距离&#xff1a; 丝印到丝印距离&#xff1a; 走…

mysql 高阶语句 与视图

目录 一 前言 二 msql 高阶语句使用方法 &#xff08;一&#xff09; 查询并排序&#xff08;order by&#xff09; 1&#xff0c;排序方式 2&#xff0c;查询指定列 并排序 3, 条件判断&#xff08;过滤指定行&#xff09; 再查询指定列 并排序 4&#xff0c;查…

Android Viewpager 内外间距

Android使用Viewpager_内外边距 代码&#xff1a; 1、adapter&#xff1a; <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_par…

Ubuntu20.04 安装 OpenCV3 过程中遇到的各种问题及其解决办法

文章目录 前言开始安装OpenCV3问题1&#xff1a;ICV: Failed to download ICV package: ippicv_linux_20151201.tgz.1.1 具体步骤 问题2&#xff1a;/usr/include/c/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory问题3&#xff1a;error: CODEC_FLAG_GLO…

安装paddle detection心得

一、安装PaddlePaddle conda create -n mypaddle python3.8 conda activate mypaddle python -m pip install paddlepaddle-gpu2.6.0 -i https://mirror.baidu.com/pypi/simple 请确保您的PaddlePaddle安装成功并且版本不低于需求版本。使用以下命令进行验证。 这是CUDA1…

通过修改ospf的COST值来控制路由选路

配置好OSPF之后,发现默认走的是上面 PC1>tracert 192.168.200.1traceroute to 192.168.200.1, 8 hops max (ICMP), press Ctrl+C to stop1 192.168.100.254 16 ms <1 ms 16 ms2 10.10.10.2 15 ms &l

科普 | Runes 预挖矿概念

作者&#xff1a;Jacky X/推&#xff1a;zxl2102492 关于 Runes 协议的前世今生&#xff0c;可以点击阅读这篇文章 &#x1f447; 《简述 Runes 协议、发展历程及最新的「公开铭刻」发行机制的拓展讨论》 什么是传统预挖矿概念 这轮比特币生态爆发之前&#xff0c;预挖矿&…

基于java+springboot+vue实现的超市货品信息管理系统(文末源码+Lw+ppt)23-355

摘 要 随着世界经济信息化、全球化的到来和互联网的飞速发展&#xff0c;推动了各行业的改革。若想达到安全&#xff0c;快捷的目的&#xff0c;就需要拥有信息化的组织和管理模式&#xff0c;建立一套合理、动态的、交互友好的、高效的超市货品信息管理系统。当前的信息管理…

YOLOv9改进策略:注意力机制 | 二阶通道注意力机制(Second-order Channel Attention,SOCA),实现单图超分效果

&#x1f4a1;&#x1f4a1;&#x1f4a1;本文改进内容&#xff1a;CVPR_2019 SOCA注意力&#xff0c;一种基于二阶通道注意力机制&#xff0c;能够单幅图像超分辨率&#xff0c;从原理角度分析能够在小目标检测领域实现大幅涨点效果&#xff01;&#xff01;&#xff01; &am…

APP测试常见功能测试点汇总

1、安装和卸载 安装和卸载是任何一款APP中都属于最基本功能。一旦出错&#xff0c;就属于优先级为紧要的BUG。因此APP的安装和卸载应作为一个测试点多加重视。 1 应用是否可以正常安装&#xff08;命令行安装&#xff1b;豌豆荚&#xff0f;手机助手等第三方软件安装&#xff…

C语言看完我这篇编译与链接就够啦!!!

1. 前言 Hello&#xff01;大家好我是小陈&#xff0c;今天来给大家介绍最详细的C语言编译与链接。 2. 编译和链接 我们通常用的编译器&#xff0c;比如Visual Sudio,这样的IDE(集成开发环境&#xff09;一般将编译和链接的过程一步完成&#xff0c;通常将这这种编译和链接合…

冗余双写方案下数据一致性问题解决及延申问题处理方案

主要整理了采用冗余双写方案后的问题解决方案。 1、问题&#xff1a;冗余双写场景下&#xff0c;如何解决数据一致性问题&#xff1f; 方案一&#xff1a; 直接RPC调用Seata分布式事务框架&#xff0c;采用该方式实现了事务的强一致性&#xff0c;代码逻辑简单的同时业务侵入…

【ORB-SLAM3】在 Ubuntu20.04 上编译 ORM-SLAM3 并使用 D435i、EuRoC 和 TUM-VI 运行测试

【ORB-SLAM3】在 Ubuntu20.04 上编译 ORM-SLAM3 并使用 D435i、EuRoC 和 TUM-VI 运行测试 1 Prerequisites1.1 C11 or C0x Compiler1.2 Pangolin1.3 OpenCV1.4 Eigen3 2 安装 Intel RealSense™ SDK 2.02.1 测试设备2.2 编译源码安装 (Recommend)2.3 预编译包安装 3 编译 ORB-S…

网络编程基本概念(一篇文章掌握基本内容的详细概念,IP,端口号,协议,协议分层,封装和分用,客户端和服务端,请求和回应,两台主机的通信)

IP地址 概念 IP地址主要⽤于标识⽹络主机、其他⽹络设备&#xff08;如路由器&#xff09;的⽹络地址。简单说&#xff0c;IP地址⽤于定位主机的⽹络地址。 就像我们发送快递⼀样&#xff0c;需要知道对⽅的收货地址&#xff0c;快递员才能将包裹送到⽬的地。 IP的格式 IP地址…

优化iproute2中的tc流控规则下发机制

设备基于IP对每个用户配置流量控制规则&#xff0c;规则如下&#xff1a; tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.0.10 flowid 1:10 上面的tc 是一个配置工具&#xff0c;本身是一个应用程序&#xff0c;tc后面的参数通过应用程序参…
最新文章