以下是常用的Android ADB(Android Debug Bridge)命令合集,这些命令可以帮助你管理和调试Android设备:
基本命令
- 检查连接的设备
adb devices
- 重启ADB服务
adb kill-server
adb start-server
设备管理
- 重启设备
adb reboot
- 恢复出厂设置(需进入Recovery模式)
adb reboot recovery
- 获取设备日志
adb logcat
- 安装APK
adb install path/to/your.apk
- 卸载应用
adb uninstall com.example.app
文件操作
- 推送文件到设备
adb push local/path remote/path
- 从设备拉取文件
adb pull remote/path local/path
Shell命令
- 进入设备Shell
adb shell
- 执行单条Shell命令
adb shell command
网络相关
- 查看IP地址
adb shell ip addr
- 端口转发
adb forward tcp:local_port tcp:device_port
性能监控
- CPU信息
adb shell top
- 内存信息
adb shell dumpsys meminfo
- 电池信息
adb shell dumpsys battery
UI自动化测试
- 启动UI Automator Viewer
uiautomatorviewer
- 运行UI测试
adb shell uiautomator runtest YourTest.jar -c your.test.ClassName
调试和问题排查
- 查看Bug报告
adb bugreport
- 查看系统属性
adb shell getprop
- 查看权限信息
adb shell pm list permissions -g
这些命令可以帮助你在开发和调试过程中更高效地管理Android设备。如果你有特定的需求或遇到具体问题,请提供更多信息,以便我能给出更详细的帮助。