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 🙁
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)
3
Answers
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...)
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:
Then I press the x button (close the emulator) immediately during the shutdown process.
Make sure you do not have any active VPN and start your emulator again using Android Studio.
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 added8.8.4.4
, as suggested in this answer, and it resolved the problem.