Android模拟器已连接到WiFi但无法上网。

huangapple go评论80阅读模式
英文:

Android Emulator Wifi Connected with No Internet

问题

我知道这个问题在Stack Overflow上已经出现多次,但是没有一个答案对我有帮助。以下是我之前尝试过的一些方法:

  • 重新启动IDE
  • 使缓存无效/重新构建项目
  • 清除数据并冷启动模拟器
  • 更改模拟器的网关和IP地址(在WiFi设置中)
  • 在模拟器文件夹内运行以下命令:.\emulator.exe -avd avd_device_name -dns-server 8.8.8.8(其中avd_device_name是正确的设备名称)
  • 飞行模式
  • 重启我的电脑和我的调制解调器
  • 创建一个不同的模拟器
  • 从.android目录中删除所有文件
  • 重新启动adb服务器
  • 连续冷启动8次
  • 更改主机机器的DNS
  • 重新启动模拟器“几次”
  • 切换WiFi按钮
  • 重新安装Android Studio(当前运行的是最新版本,但没有改变)
  • 降级Android Studio
  • https://stackoverflow.com/a/44214842/15749574 <- 不知道如何描述这个,但我尝试了
  • 检查“使用Android Studio HTTP代理设置”选项

我没有使用VPN,模拟器昨天还正常工作(我猜是在关闭电脑后再次启动后出现问题的),我没有使用LAN连接。

我重新发布这个问题是因为我在这个问题上已经花了最后15个小时,但仍然没有解决 Android模拟器已连接到WiFi但无法上网。

通常情况下,我会重新安装整个操作系统(目前是Windows 11)(我一点也不耐烦 XD),但这是公司的机器,我怀疑我是否有“必要的权限”,如果你知道我的意思的话。

更新:
我重新安装了操作系统,模拟器在公司的WiFi上正常工作,但当我回到家后又出现了问题,所以这可能是一个网络问题吗?(我在同一个网络上有一台个人电脑,那台电脑上的模拟器工作得很好,我很困惑)

英文:

I know this question has appeared multiple times on SO, but NONE of the answers helped, here's a list of what I've tried before:

  • restarting the IDE
  • invalidating the caches / rebuilding project
  • wiping data & cold booting the emulator
  • changing the gate and IP adress of the emulator (inside the wifi settings)
  • .\emulator.exe -avd avd_device_name -dns-server 8.8.8.8 (the command with the correct avd_device_name, run inside the emulator folder)
  • airplane mode
  • Restarting my pc and my modem
  • Creating a different emulator
  • removing all files from .android dir
  • restarting the adb-server
  • cold-booting 8 times in a row
  • Changing the DNS of the host machine
  • Restarting the emulator "a couple of times"
  • toggling the wi-fi button
  • literally reinstalling android studio (currently running the newest version, it changed nothing)
  • downgrading android studio
  • https://stackoverflow.com/a/44214842/15749574 <- don't know how to even describe that one, but I tried it
  • checking the "Use Android Studio HTTP proxy settings" option

I am not using a VPN, the emulator was working fine yesterday (things went wrong after shutting down the pc and starting it up again I guess?), I am not using a LAN connection

I'm starting the question again to seek help cause I've spent the last 15 hours on this and IT'S STILL NOT WORKING Android模拟器已连接到WiFi但无法上网。

I would normally just reinstall all of the OS (currently: Windows 11) (I'm not patient at all XD), but that's the company machine and I doubt that I have the "necessary powers" if you know what I mean

Update:
I've got an OS reinstall, the emulator worked fine on the company's wifi, but when I went back home it happened again, so it might be a network problem? (I've got a personal pc on the same network and the emulator on that pc works like a charm, I'm so confused)

答案1

得分: 1

可能有多种原因,但macOS和Windows上模拟器连接问题的常见原因之一是主机计算机上的DNS设置与网络连接的IP地址不匹配。

我还知道这会影响Windows计算机上本地Kubernetes集群的出站连接。不久前,我花了几天的时间才解决了Kubernetes的问题。

最近,我在macOS上遇到了一个相关的模拟器问题,只有模拟的3G T-Mobile连接起作用,而模拟的Wifi连接不起作用。我查看了我的macOS主机计算机的网络连接,只包括8.8.8.8。然后我按照这个答案的建议添加了8.8.4.4,问题得以解决。

英文:

There could be multiple causes, but a common cause of connectivity issues for emulators on both macOS and Windows is DNS settings against the IP address of the network connection on the host computer.

I have also known this to impact outbound connections from local Kubernetes clusters on Windows computers. A while back, it took me days of head scratching to resolve the Kubernetes problem.

I recently had a related emulator issue on macOS, where only the simulated 3G T-Mobile connection worked, and not the simulated Wifi. I looked at my host computer's network connection on macOS and it included only 8.8.8.8. I then added 8.8.4.4, as suggested in this answer, and it resolved the problem.

Android模拟器已连接到WiFi但无法上网。Android模拟器已连接到WiFi但无法上网。

答案2

得分: 0

这是我遇到这个问题时的解决方法:
我通过长按电源按钮并在屏幕上选择关机的方式来关闭模拟器,如下所示:

Android模拟器已连接到WiFi但无法上网。

然后在关机过程中立即按下x按钮(关闭模拟器)。

Android模拟器已连接到WiFi但无法上网。

确保您没有正在运行的 VPN,然后再次使用 Android Studio 启动您的模拟器。

英文:

It is my solution when I encounter this problem:
I shut down the emulator using the long click on the power button and select the power off on the screen like so:

Android模拟器已连接到WiFi但无法上网。

Then I press the x button (close the emulator) immediately during the shutdown process.

Android模拟器已连接到WiFi但无法上网。

Make sure you do not have any active VPN and start your emulator again using Android Studio.

答案3

得分: 0

终于成功解决了问题!(但这篇帖子仍然开放给其他解决方案,因为我肯定是幸运的,可能还有许多其他问题会导致相同的问题)

在重新安装操作系统并尝试在公司网络上使用后,它按照预期工作,但当我把电脑带回家并启动它时...同样的问题发生了,现在我确信这不是硬件问题,也不是“与Windows相关”的问题(驱动程序等),所以唯一剩下的就是防火墙(和/或可能中断互联网流量的其他软件),我进入了Wi-Fi设置并将我的Wi-Fi标记为“私有”(而不是公共),然后重新启动模拟器,它最终正常工作!

(副注:解决这个问题花了我大约4天...)

英文:

Finally managed to solve the issue! (but this post is still open to other solutions, cause definitevely I got lucky and there could be many other issues that would lead to the same problems)

After getting a fresh install of my OS and trying it out on the company network it was working as it is supposed to do, but when I took the pc home and started it up... the same stuff happened, now I was sure that it was not a hardware problem, nor a "windows related" (drivers etc.) problem, so the only thing left was the firewall (and/or other software that may interrupt the internet flow), I went into the wifi settings and marked my wi-fi as "private" (not public), cold booted the emulator and it finally worked!

(side note: Solving this took me about 4 days...)

huangapple
  • 本文由 发表于 2023年3月4日 04:17:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75631532.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定