Windows下使用adb实现在模拟器中ping

文章目录

前言

有时在模拟器中测试应用不像在Windows这种开发环境中那么方便,毕竟Windows或者Linux下的工具五花八门,可以满足各种测试需求,比如应用在模拟器中无法登录时,想测试模拟器的网络情况,如果是在Windows或者Linux下各种网络工具任君挑选,但是在模拟器中运行个命令行下的ping命令的都费劲,但方法还是有的,我就找个不那么费劲的方法吧,记录在此方便查阅。

安装adb

adb(Android Debug Bridge)是一个命令行工具,用于与 Android 设备或模拟器进行交互。它是 Android SDK 的一部分,广泛用于开发、调试和管理 Android 应用程序和设备,如果我们仅是简单使用,不必安装完整的 Android SDK,直接下载Google提供的adb工具包,下载后解压即可使用。

Windows中下载解压后需要将加压后的文件夹添加到Path环境变量,按键windows+i打开设置界面搜索"环境变量"回车。

在选项 环境变量 -> 系统变量 -> Path 输入解压后端的文件夹,比如 D:\platform-tools\ 确定后保存

打开CMD命令行工具输入 验证,显示如下类似信息证明工具已经就位

bash 复制代码
C:\Users\Administrator>adb --version
Android Debug Bridge version 1.0.41
Version 35.0.2-12147458
Installed as D:\ProgramNoBlank\platform-tools\adb.exe
Running on Windows 10.0.18363

执行adb命令

有了adb就可以和连接了电脑的Android设备通信,Android模拟器也可以看成是安装设备,首先要找到模拟器设备id

查找模拟器设备

bash 复制代码
C:\Users\Administrator>adb devices
List of devices attached
C:\Users\Administrator>adb devices
List of devices attached
emulator-5554   device

链接模拟器命令行

bash 复制代码
C:\Users\Administrator>adb -s emulator-5554 shell
OP564B:/ $

执行ping命令

bash 复制代码
OP564B:/ $ ping 008ct.top
PING 008ct.top (198.18.0.152) 56(84) bytes of data.
64 bytes from 198.18.0.152: icmp_seq=1 ttl=64 time=0.636 ms
64 bytes from 198.18.0.152: icmp_seq=2 ttl=64 time=1.13 ms
64 bytes from 198.18.0.152: icmp_seq=3 ttl=64 time=1.39 ms
64 bytes from 198.18.0.152: icmp_seq=4 ttl=64 time=1.57 ms
64 bytes from 198.18.0.152: icmp_seq=5 ttl=64 time=1.51 ms
^C
--- 008ct.top ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4009ms
rtt min/avg/max/mdev = 0.636/1.251/1.579/0.344 ms

总结

  • adb 是一个命令行工具,属于 Android SDK 的一部分,用于与 Android 设备或模拟器进行交互
  • 借助 adb 工具可以实现在宿主机上调试和处理Android设备或模拟器上的应用
  • 查询机器连接的Android设备列表命令 adb devices
  • 连接Android模拟器中的命令行工具的命令 adb -s emulator-5554 shell

==>> 反爬链接,请勿点击,原地爆炸,概不负责!<<==


曾国藩、左宗棠、洪秀全分别相差1岁,命运却迥然不同,左宗棠第一次见曾国藩的评价居然是"才具稍欠开展",命运戏人啊

相关推荐
大王派来巡山的小旋风20 分钟前
Kotlin基本用法之集合(一)
android·程序员·kotlin
用户20187928316723 分钟前
智能广播系统(RemoteCallbackList)的诞生
android
LZQqqqqo1 小时前
C# 中 ArrayList动态数组、List<T>列表与 Dictionary<T Key, T Value>字典的深度对比
windows·c#·list
季春二九1 小时前
Windows 11 首次开机引导(OOBE 阶段)跳过登录微软账户,创建本地账户
windows·microsoft
用户2018792831672 小时前
Binder 同应用内(本地)通信是否存在 1MB 大小限制?
android
一条上岸小咸鱼2 小时前
Kotlin 基本数据类型(四):String
android·前端·kotlin
芥子沫2 小时前
Jenkins常见问题及解决方法
windows·https·jenkins
Onion_993 小时前
学习下Github上的Android CICD吧
android·github
来来走走3 小时前
Flutter Form组件的基本使用
android·flutter
顾林海4 小时前
Android MMKV 深度解析:原理、实践与源码剖析
android·面试·源码阅读