I am using Android Studio 2.3(Latest). Till yesterday it was all good and working, today emulator is not connecting to the data network.
I couldn\'t find any solution wo
If you have Blue Coat Unified Agent, internet wont work. Kindly uninstall it.
It can be uninstalled by going to below folder- /Library/Application Support/bcua
It's a bug with IPv6 name resolution, removing any IPv6 nameserver in /etc/resolv.confg
fixes the issue, see https://issuetracker.google.com/issues/155686508#comment3
I'm new to Android Studio and just ran into this issue. Network in the sim was working fine and stopped working for some reason. Didn't like any of the solutions above, so I poked around the AVD Manager and found an option to wipe the data on the sim.
Go to open AVD manager and click wipe data
That's it now the Internet will work. This is how I solved my Issue.
if its an android project, u can change the baseUrl to 10.0.2.2, note this is only applicable from android emulator, will not work on phone
e.g Api endpoint will now look like this: val baseUri : String = "http://10.0.2.2/restapi/"
val loginEndpoint = "${baseUri}login"
In Mac OS go to:
System Preferences -> Network -> select Wi-Fi os left panel -> Advanced on right panel -> DNS -> add new DNS server; for example 8.8.8.8
and 8.8.4.4
(Google Public DNS) or 1.1.1.1
and 1.0.0.1
(Cloudflare and APNIC DNS) or another public DNS provider. Then restart the emulator so the changes take effect.
Edited jun/2020
Another option is to pass dns-server params when start Android emulator.
According with this solution https://stackoverflow.com/a/51858653/3328566, I changed the emulator executable name and I created a bash script to load the AVD with param -dns-server 8.8.8.8
.
In your Android SDK default folder /Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator
emulator
to emulator_original
emulator
that contains: #!/bin/bash
/Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator_original -dns-server 8.8.8.8 $@
chmod +x emulator
Now, you can start AVD from Android Studio normally
In this case, you don't need to set DNS server in System Preferences. You are setting the DNS server only for the emulator, avoiding other problems