美文网首页
常用adb命令

常用adb命令

作者: w达不溜w | 来源:发表于2022-09-08 14:07 被阅读0次
  • 连接设备
adb connect <ip>:<port>
  • 设备连接情况
adb devices
  • 断开连接
adb disconnect
  • 关闭adb服务
adb kill-server
  • 启动adb服务
adb start-server
  • 查看设备属性
adb shell getprop
adb shell getprop ro.mac
  • 安装
adb install <apk路径>
  • 覆盖安装
adb install -r <apk路径>
  • 卸载
adb uninstall <包名>
  • 启动activity
adb shell am start -n <包名>/<类名>
adb shell am start --ei age 18 --es name "sun" -n <包名>/<类名>

说明:-n表示component名(包名+类名)--ei表示参数类型为整型 --es表示参数的类型为字符串 --ez表示boolean值

  • 启动service
adb shell am startservice -n <包名>/<类名>
adb shell am startservice --es id "123" -n <包名>/<类名>
  • 启动broadcast
adb shell am broadcast -a <action> --es taskId "123" <包名(发送指定包名的广播)>

说明:-a表示的是action

  • 强制停止运行程序
adb shell am force-stop <包名>
  • 查看设备里所有的包名
adb shell pm list packages
  • 查看手机里面所有第三方包名
adb shell pm list packages -3
  • 清除缓存数据
adb shell pm clear <包名>
  • 抓日志
adb logcat <过滤包名> -v time > /Users/sun/logcat.txt
  • 导出
adb pull <设备路径> <电脑路径>
  • 导入
adb push <电脑路径> <设备路径>
  • 获取设备mac地址
adb shell cat /sys/class/net/wlan0/address
  • 查看当前activity
adb shell "dumpsys window | grep mCurrentFocus"
  • 查看app内存
adb shell dumpsys meminfo <包名>
  • 获取包名的安装路径
adb shell pm path <包名>
  • 模拟按键事件
adb shell input keyevent <KeyCode>

adb shell input keyevent 4 home 
adb shell input keyevent 4 返回 
adb shell input keyevent 19 上  
adb shell input keyevent 20 下   
adb shell input keyevent 21 左   
adb shell input keyevent 22 右
adb shell input keyevent 23 确定
...
  • activity的调用栈信息
adb shell dumpsys activity activities
  • 访问数据库SQLite3
adb shell   进入shell
cd /data/data/<包名>/databases  进入数据库文件夹
ls  查看文件
sqlite3 xxx.db  访问数据库
.table  查看表
select * from <table>;  sql语句,注意要加分号
  • 根据包名查看版本号
adb shell dumpsys package <包名> | grep "version"
  • 设置代理
adb shell settings put global http_proxy <ip>:<port>
  • 查看代理
adb shell settings get global http_proxy
  • 删除代理
adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_port

相关文章

网友评论

      本文标题:常用adb命令

      本文链接:https://www.haomeiwen.com/subject/njlonrtx.html