本网站是本人的个人博客网站海外站,国内网站为https://suyihang15.com,本网站主要面对海外用户

电脑adb连接模拟器

在一般要测试一些脚本时可以用这种方式在电脑上跑命令

1、前提条件

adb下载

windwos端下载 https://dl.google.com/android/repository/platform-tools-latest-windows.zip

macos端下载 https://dl.google.com/android/repository/platform-tools-latest-windows.zip

linux端下载 https://dl.google.com/android/repository/platform-tools-latest-linux.zip

解压

2、改环境变量

选择好解压下来的adb.exe就行了

查看已连接设备

.\adb devices

连接 MuMu 模拟器(常用端口:16384 / 5554)

.\adb connect 127.0.0.1:16384

断开设备

.\adb disconnect 127.0.0.1:16384

重启 adb 服务

.\adb kill-server
.\adb start-server
 

二、模拟操作(自动化脚本最常用)

点击坐标 (x,y)

.\adb shell input tap x y

滑动(起点x1 y1 → 终点x2 y2,时长300ms)

.\adb shell input swipe x1 y1 x2 y2 300

输入文字

.\adb shell input text “你要输入的内容”

按返回键

.\adb shell input keyevent 4

按 Home 键

.\adb shell input keyevent 3
 

三、安装 / 卸载 APP

安装 APK

.\adb install 路径/xxx.apk

强制覆盖安装(更新用)

.\adb install -r 路径/xxx.apk

卸载 APP(需要包名)

.\adb uninstall 包名
 

四、文件传输(电脑 ↔ 模拟器)

电脑 → 模拟器

.\adb push 电脑文件路径 /sdcard/

模拟器 → 电脑

.\adb pull /sdcard/文件名 电脑保存路径
 

五、查看与截图

截图并保存到电脑

.\adb shell screencap -p /sdcard/screen.png
.\adb pull /sdcard/screen.png 电脑路径

查看屏幕分辨率

.\adb shell wm size
 

六、APP 相关

查看当前打开的 APP 包名

.\adb shell dumpsys window | findstr mCurrentFocus

启动 APP

.\adb shell am start -n 包名/Activity名

强制停止 APP

.\adb shell am force-stop 包名
 

你现在最常用的(直接记这几个)

.\adb devices # 看设备
.\adb connect 127.0.0.1:16384 # 连 MuMu
.\adb shell input tap x y # 点击
.\adb shell input swipe x1 y1 x2 y2 300 # 滑动

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

阿里云云服务器ECS - 特惠选购

精选服务器规格

入门服务器

入门型实例

适合个人博客、小型网站、学习测试,2核2G,带宽可选。
¥99.00 /年起
查看详情
企业基础服务器

企业基础实例

4核8G配置,中小型业务、商城、小程序后端,稳定高性能。
¥399.00 /年起
查看详情
高性能服务器

高性能计算实例

高CPU大内存,数据库、高并发业务场景,支撑业务高峰期。
¥899.00 /年起
查看详情

产品核心优势

⇄

弹性伸缩

随时升降配置,业务涨降灵活调整,避免资源浪费

🛡

安全防护

DDoS基础防护,防火墙,保障服务器业务安全

✓

高可用稳定

多可用区,高服务可用性,降低故障风险

⚙

简单运维

控制台可视化操作,支持Windows/Linux多种系统