0
点赞
收藏
分享

微信扫一扫

UNI-APP小程序答题功能开发(左右滑动,判断,填空,问答,答题卡,纠错,做题倒计时等)

盖码范 2024-11-18 阅读 11
androidadb

文章目录


前言

常用的 Android ADB(Android Debug Bridge) 指令大全,涵盖了设备管理、应用管理、调试等常见操作。

1. 设备管理

1.1 连接设备

adb devices              # 显示连接的设备列表

连接到指定设备(通过序列号)

adb -s <device_serial> shell

连接到设备(通过 IP 地址)

adb connect <device_ip>:5555

1.2 断开与设备的连接

adb disconnect

1.3 查看设备详细信息

adb shell getprop        # 获取设备的系统属性

1.4 查看设备状态

adb devices -l           # 显示设备的详细信息(包括型号、状态等)

重启设备

adb reboot               # 重启设备
adb reboot bootloader    # 进入bootloader模式
adb reboot recovery      # 重启到恢复模式

2. Shell 操作

2.1进入设备的 Shell(命令行模式)

adb shell     # 进入设备的 shell 环境。

2.2 执行单个命令

adb shell <command>
# 在设备上执行单个命令 ,例如:
adb shell ls /sdcard

2.3查看设备上的进程

adb shell ps

3. 文件操作

3.1 推送文件到设备

adb push <local_path> <remote_path>

# 将本地文件推送到设备。例如:
adb push localfile.txt /sdcard/remote_file.txt

3.2 从设备拉取文件到本地

adb pull <remote_path> <local_path>
# 在这里插入代码片从设备拉取文件到本地。例如:
adb pull /sdcard/remote_file.txt ./localfile.txt

3.3 删除设备上的文件

adb shell rm <file_path>
# 删除设备上的文件。例如:
adb shell rm /sdcard/test.txt

3.4 查看设备上的文件或目录

adb shell ls <path>
# 列出设备目录的内容。例如:
adb shell ls /sdcard

4. 应用管理

4.1 安装 APK 到设备

adb install <apk_path>
# 安装 APK 文件。例如:
adb install myapp.apk

4.2 卸载应用

adb uninstall <package_name>
# 卸载设备上的应用。例如:
adb uninstall com.example.myapp

4.3 启动应用

adb shell am start -n <package_name>/<activity_name>
# 启动指定应用。例如:
adb shell am start -n com.example.myapp/.MainActivity

4.4 强制停止应用

adb shell am force-stop <package_name>
# 强制停止指定的应用。例如:
adb shell am force-stop com.example.myapp

5. 日志和调试

5.1 查看 logcat 日志

# 输出设备的日志信息。
adb logcat

# 查看特定标签的日志
adb logcat -s <tag>
# 查看特定标签的日志。例如:
adb logcat -s ActivityManager

5.2 将日志保存到文件

adb logcat -d > <logfile_path>
# 将日志输出到文件。例如:
adb logcat -d > log.txt

6. 网络操作

6.1 查看设备的 IP 地址

adb shell ip addr show wlan0
# 显示设备的 IP 地址。

6.2 启用 Wi-Fi 调试(USB 连接后)

adb tcpip 5555 #在设备上启用通过 Wi-Fi 调试。

6.3 关闭 Wi-Fi 调试

adb usb #切换回 USB 调试模式。

7. 其他实用命令

7.1 查看设备属性

adb shell getprop  #显示设备的所有属性。

7.2 更改设备的系统属性

adb shell setprop <key> <value>
# 设置设备的系统属性。例如:
adb shell setprop persist.sys.timezone Asia/Shanghai

7.3 获取设备的硬件信息

adb shell cat /proc/cpuinfo # 显示设备的 CPU 信息。

7.4列出设备上的所有进程

adb shell ps

8. 其他有用的调试命令

8.1 查看设备当前的运行状态

adb shell dumpsys

8.2 使用指定端口转发

adb forward tcp:<local_port> tcp:<device_port> #将本地端口映射到设备端口。

8.3 停止 ADB 服务器

adb kill-server

8.4 启动 ADB 服务器

adb start-server
举报

相关推荐

0 条评论