Android Studio - Android Emulator Wifi Connected with No Internet

AndroidAndroid StudioAndroid EmulatorAndroid Wifi

Android Problem Overview


I have wasted a whole day trying out different solutions floating around in SO and other place mentioned to enable wifi on the android emulator but to no avail. Can anybody help me figure out how do I enable internet on my android emulator?

I have Nexus 5X API 27 and target being Android 8.1 (Google Play) and Nexus 5 API P and target being Android 7.1.1.

I believe there should be a way to enable internet on it or else the whole point of providing virtual wifi on the emulator seems to be waste.

I am on mac OS HS 10.13.4 directly connected to my router with no proxy.

I even tried deleting all the AVDs, re-installing them. I even tried having installed the latest Pixel 2 with Oreo Android 8.1

Nothing seems to be working. Has anybody faced this issue and found a solution?

Any help would be of great help

Thanks, Vikram

Update: When I connect my computer through my phone as hotspot wifi, the emulator has internet through wifi, but it fails when I connect my computer to my home router.

Android Solutions


Solution 1 - Android

Stated below are the solutions for Windows and Mac, but similar solutions will work on any OS:

  1. On Windows
  • Open Network and Sharing Center and click on current Connection

  • Click on Properties

  • Double Click on Internet Protocol Version 4 (TCP/IPv4)

  • Set the Preferred and Alternate DNS servers as (Screenshot below) :

        8.8.8.8
        8.8.4.4
    
  1. On Mac
  • Go to Settings > Network > Advanced... > DNS

  • Delete whatever entries you have there and add these two entries (Screenshot below):

        8.8.8.8
        8.8.4.4
    

Note: For Mac users, if the entries field is disabled and you're not able to edit it, click on the 'Lock' icon in the bottom area of that window and enter the password to be able to make changes

Restart the emulator, and it should solve:

Screenshots:

  1. Windows

Android emulator not connecting to internet solution on windows

  1. Mac

Android emulator not connecting to internet solution on a mac


Edit: This is the fix for a situation when the emulator's wifi has changed the DNS to some non-working DNS. While this works most of the time, there might also be other reasons which may not fix from this solution.

Solution 2 - Android

My solution using Mac OSX 10.13

I read about it being caused by LAN card and WiFi being enabled, and some approaches seemed complicated to me, so I simply tried this, and it worked:

  • Disabled WiFi on my laptop.

  • Switched off the emulator.

  • Did a cold boot on the emulator (AVD Manager -> on emulator actions -> Cold Boot Now).

  • After reboot with laptop WiFi disabled the emulator showed proper WiFi connection (emulator still shows AndroidWifi but is connected to my laptop internet. WiFi symbol now look like this: WiFi symbol connected)

  • I then enabled WiFi on my laptop and everything worked.

Solution 3 - Android

It seems the previous answers to this problem no longer work in 2021 (Using Android Studio 4.1.2). The problem is the DNS settings on the Emulator. It no longer works to just change the DNS Servers on your local PC. You have to change the DNS settings within the Emulator. The following steps are for an emulator running Android 11. Other versions will be similar:

  1. Open the Extended controls dialog that opens up to the right of the emulator. Click on Settings on the dialog menu. Click on Proxy at the top and make sure Use Android Studio Http proxy settings IS CHECKED. I emphasis this because many of the previous solutions said to uncheck this. However, on the latest versions, it works better to keep this checked. If it wasn't already checked, restart the emulator before proceeding Step 2
  2. Navigate to the WiFi connection settings within the emulator: Home Screen -> Swipe up -> Settings -> Network & Internet -> WiFi AndroidWifi -> click gear icon -> click Advanced dropdown near bottom of screen -> Swipe up to view to view Network Details.
  3. What does it say for DNS. If it is NOT 8.8.8.8, follow this to fix. Write down (or remember) the IP address and Gateway address displayed there in the network settings. We need those IP addresses to fill in as static.
  4. Click the pencil icon on the top to edit the Network details. Click the IP settings dropdown and change it to Static. Then enter the IP address and Gateway that you wrote down in step 2. Make sure DNS 1 is 8.8.8.8 and DNS 2 is 8.8.4.4. These filled in automatically for me.
  5. Close the emulator and restart it using the Cold Boot Now option.

This fixed it for me after I unsuccessfully tried all the other solutions found on this page and many others. I hope it works for you.

Solution 4 - Android

@TheBaj : I figured the problem with this and fixed it. The problem is when you are connected through the router, the androidwifi in your emulator uses the settings and the sets the DNS to something other than 8.8.8.8 which is the google DNS(I presume this is kinda mandatory setting for the androidwifi to gain internet access). But if i change the DNS in my network settings, the google-services plugin which fetches your dependencies especially the one's getting downloaded from jcenter() will not be downloaded and hence your sync will fail which eventually fails your build.

So the trick is that you have your google DNS(8.8.8.8) configured in your network settings after your default router settings - this part takes care of downloading the dependencies from jcenter() and the sync and build succeeds.

Now launch your emulator with emulator @Nexus_5X_API_27 -dns-server 8.8.8.8 command from the terminal which forces the emulator to use 8.8.8.8 as its DNS and the emulator will have internet.

I am working on a react-native app, so for me android studio is needless and i have configured my bashrc to launch the different emulators as follows,

   function emunex5 {
    emulator @Nexus_5X_API_27 -dns-server 8.8.8.8
 }

  function emunex6 {
    emulator @Nexus_6_API_27 -dns-server 8.8.8.8
  }

  function emupix {
    emulator @Pixel_XL_API_27 -dns-server 8.8.8.8
   }

So from one terminal i launch the emulator of my choice and then run the build on another terminal which runs my app on the launched emulator and MY FREAKING EMULATOR HAS INTERNET ACCESS. :)

Try this out and i hope this helps.

Thanks, Vikram

Solution 5 - Android

On macOS:

  1. Open Network in System Preferences.
  2. Select your current network from left side then click Advanced....
  3. Change Configure IPv6(under TCP/IP tab) from Automatically to Link-local only.
  4. Restart your emulator.

Solution 6 - Android

Solution for Windows:

  1. Go to your Android SDK Location, E.g.: C:\Users\shehzad\AppData\Local\Android\Sdk\emulator.
  2. Open Command Prompt on same location. Write this command: emulator -avd Nexus_4_API_29 -gpu host -dns-server 8.8.8.8. Here Nexus_4_API_29 will be your emulator device name (You can find it out devices list from Android Studio -> AVD Manager). This command will run your specified device and WIFI will have Internet connected.

Hope this helps.

Solution 7 - Android

I was having the same issue and following the below steps resolved it.

Steps:

  1. Go to Emulator Settings
  2. Select Proxy Tab
  3. Then check the "Use Android Studio HTTP proxy settings" option
  4. Click Apply

Solution 8 - Android

On Mac OSX (Catalina for me), the problem is caused by the fact that the emulator automatically picks up the nameserver by looking at /etc/resolv.conf and picking the first one, in my case an IPv6 address. Source: https://developer.android.com/studio/run/emulator-networking#dns

Simply edit the file (sudo vi /etc/resolv.conf) and move the IPv4 address (192.168.1.1 in my case) to be first, before the IPv6 addresses. Seriously, that was it.

Solution 9 - Android

I have solved with google dns on network adapter 8.8.8.8 and 8.8.4.4

Android Emulator wifi connected with no internet solution for windows

Solution 10 - Android

Wipe data by right clicking on virtual device list & cold boot works for me..

Solution 11 - Android

Well, I did it this way:

Steps to add manual proxy:

  1. Go to Emulator settings
  2. Go to Proxy tab
  3. Set Manual proxy configuration
  4. Add your Host name & Port number
  5. Click on Apply

Reference screen shot:

enter image description here

Hope it helps.

Solution 12 - Android

100% Working on Windows 10

Android AVD come with Google DSN configured inside emulators. So we need to set same to network sharing for accessing same.

Google Public DNS IP addresses The Google Public DNS IP addresses (IPv4) are as follows:

8.8.8.8

8.8.4.4

The Google Public DNS IPv6 addresses are as follows:

2001:4860:4860::8888 2001:4860:4860::8844 You can use either address as your primary or secondary DNS server.

More Info

Here I show for setting v4 IP steps

  1. Open Network and Sharing Center
  2. Right Click on current internet connection
  3. Select Properties
  4. Double Click on Internet Protocol Version 4 (TCP/IPv4)
  5. Select Use the following DNS server address
  6. Set the Preferred and Alternate DNS server
  7. Prefered DNS Server : 8.8.8.8
  8. Alternate DNS Server : 8.8.4.4
  9. Click on OK
  10. Restart Android AVD

Note : If VPN is enabled then it will not work need to disconnect your VPN

More info on Google DSN

Solution 13 - Android

My environment is Android Studio 4.2.0 in Mac 11.3.1 Big Sur

Step 0. I close all of my emulator, and close Android Studio too .

Step 1. Then I open Android Studio. AVD Manager -> Cold Boot Now enter image description here

Step 2. Close Wifi on emulator. Then LTE can work enter image description here

Step 3. (Optional) By the way, My DNS setting of my mac Network is enter image description here

If step0 -> step 1 -> step 2 is not work, you can set DNS like step 3. and then go through Step0 -> Step1 -> Step2 again.

And it will work.

Solution 14 - Android

Maybe this would help someone. I tried all the solutions above. Changing DNS, cold booting, etc. After several hours of trial and error, I went to the official docs, which said that the emulator picks up the DNS config. of host machine at emulator's boot time. I had VMWare installed on my machine, which installs a few network adapters. So, I just changed the DNS config. of all the adapters (including VMWare adapters), and cold booted my emulator. OMG, the problem which didn't seem to go away for hours, just got right!

Now, what I find odd is, I switched back the DNS config. of all the adapters to auto, and cold booted my emulator again. The WiFi still works just fine. OS: Windows 10.

Solution 15 - Android

If you have any VPN connected - try disconnecting it.

For me it was VPN through Cisco AnyConnect Secure Mobility Client. Once I've closed the Cisco client (which terminates the VPN connection), WiFi on Android emulator started working.

Solution 16 - Android

On Windows :

After testing some solutions, I found my one by clicking the down arrow on the AVD, option "Cold Boot Now". after booting, Android had access to internet so it worked for me.

Solution 17 - Android

I hope I save someone a lot of pain, I tried everything everyone said on here, changed the DNS of every network adapter, reinstalled everything, the SDK, the emulator, even android studio, nothing worked, if you find yourself in the same position check if you VMware installed, if you do, don't bother with the DNS just go into Control Panel->Network and Sharing Center->Change Adapter Settings, and disable any and all VMware Network Adapters, then Cold Boot, fixes the issue instantly, you can even enable them later, and it still works

Solution 18 - Android

What worked for me:

  • Power off the emulator (using its power key)
  • Start your app on ANOTHER emulator and then close it.
  • Now start your app in previous emulator again.

Solution 19 - Android

A simple cold boot worked for me, no need to start other emulators or wiping memory.

Just close your emulator and select the "Cold Boot Now" option on the drop menu adjacent to the play button. If not look for any of the more comprehensive options listed here, but I suggest always starting with the simplest solution.

Good luck!

Solution 20 - Android

Solution for issue on Apple M1:

  1. Install one of the newest canary versions of Android Studio. Use the MAC ARM version (Apple Silicon).
  2. When creating a new virtual device use API Level S and arm64 virtual image. (could be found in other images)

Here is the link for the android studio releases list: https://developer.android.com/studio/archive

(Worked for me)

Solution 21 - Android

If the wifi spot has changed, simple restart the emulator so the emulator refresh network settings from dhcp service.

Solution 22 - Android

Resetting Network Settings on Android Emulator fixes this issue.

Solution 23 - Android

For new searcher users: Sometimes VPN is your solution Changing of network setting is not possible always because of networking issues. If you are in ip addresses that google does not responding for these regions,your solution is using of vpn.Use a proper vpn (a vpn that trough it you could update your android studio).When your vpn is on start your avd device (ofcourse api level of your emulator is important for example I have not any problem with api 22 but for api 28 is need using of vpn !).This was my experience about android emulator internet.

Solution 24 - Android

Change the location of the emulator and set it to your current location.

  • Steps : -

    1. Click on More in emulator options
    2. Go to location
    3. Search your address and click SET LOCATION

Solution 25 - Android

I had the same issue - in the emulator I was connected to the wifi/lte but I couldn't access any website.

The solution for me was to fix the IP of my home DNS server:

$ cat /etc/resolv.conf 
search home
nameserver 192.168.1.1 #was 192.168.0.1 - it used to work when I was connected to a different router
nameserver 1.1.1.1
nameserver 1.0.0.1

you don't really need to use google dns

Solution 26 - Android

If anyone quick fix:

Step 1: Go to AVD Manager

Step 2: Stop the device

Step 3: Run Android Studio project

Solution 27 - Android

Under Extended Controls ( which can be enabled by pressing the more button (3 dots ... ) at bottom.

Then under Proxy tab, Select no proxy.

Solution 28 - Android

Maybe try using LAN if available. That works as a charm for me...

Solution 29 - Android

I had a similar problem that was kind of weird. The emulator used to work just fine but then I went to a cafe and connected to their wifi then the emulator wifi stopped working. I wiped the data made cold boot from the AVD manager then everything worked without any change in settings. I guess cold boot only would have worked without wiping data so you might try that before wiping the data.

Solution 30 - Android

On Android Studio 4.2, I was experience this issue where both Emulator Wifi/LTE was connected but no internet.

Solutions that did NOT work for me: Turning Wifi on and off, setting location/proxy, cold booting, wiping data, VPN, etc. None of the other solutions were working.

Solution that worked for me: Upgrading to Android Studio 4.2.1 and rebooting emulator.

Solution 31 - Android

This may not solve everyone's problem but I disconnected my wifi and used the Ethernet connection. This resolved my issue.

Solution 32 - Android

None of this worked for me then I turned on "Mobile HotSpot" on windows. It exists on Taskbar next to "Airplane Mode". Everything started working.

Solution 33 - Android

I tried all the above in WINDOWS 11 system without results. Finally i ran the check disk - chkdsk c: /f /r - and after PC restart i recreated the device. And it's finally worked.

Solution 34 - Android

Try disabling your antivirus and then restart your emulator that helped in my case.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVikram MahishiView Question on Stackoverflow
Solution 1 - AndroidRaman SahasiView Answer on Stackoverflow
Solution 2 - AndroidJuangui JordánView Answer on Stackoverflow
Solution 3 - AndroidideaztechView Answer on Stackoverflow
Solution 4 - AndroidVikram MahishiView Answer on Stackoverflow
Solution 5 - AndroidVincent SitView Answer on Stackoverflow
Solution 6 - AndroidShehzad OsamaView Answer on Stackoverflow
Solution 7 - AndroidPraneethView Answer on Stackoverflow
Solution 8 - AndroidDemetrios ChristopherView Answer on Stackoverflow
Solution 9 - AndroidMarcus J.KennedyView Answer on Stackoverflow
Solution 10 - AndroidindrakulaView Answer on Stackoverflow
Solution 11 - AndroidHiren PatelView Answer on Stackoverflow
Solution 12 - AndroidVinayakView Answer on Stackoverflow
Solution 13 - AndroidMilo ChenView Answer on Stackoverflow
Solution 14 - AndroidShesha Vishnu PrasadView Answer on Stackoverflow
Solution 15 - AndroidAdomasView Answer on Stackoverflow
Solution 16 - AndroidHamid ShojaView Answer on Stackoverflow
Solution 17 - AndroidiamnikView Answer on Stackoverflow
Solution 18 - AndroidM. Usman KhanView Answer on Stackoverflow
Solution 19 - AndroidEduardo A del Corral LiraView Answer on Stackoverflow
Solution 20 - AndroidluvisoniastyView Answer on Stackoverflow
Solution 21 - AndroidMiguelSlvView Answer on Stackoverflow
Solution 22 - AndroidMachineBreakerView Answer on Stackoverflow
Solution 23 - AndroidmaniaqView Answer on Stackoverflow
Solution 24 - AndroidGagan RaghunathView Answer on Stackoverflow
Solution 25 - AndroideeqkView Answer on Stackoverflow
Solution 26 - AndroidFaisal ShaikhView Answer on Stackoverflow
Solution 27 - Androidnaheed.shamimView Answer on Stackoverflow
Solution 28 - AndroidSenthil kumar MoorthyView Answer on Stackoverflow
Solution 29 - AndroidTysseerView Answer on Stackoverflow
Solution 30 - AndroidbboyairwreckView Answer on Stackoverflow
Solution 31 - AndroidJayowlView Answer on Stackoverflow
Solution 32 - AndroidGOKUView Answer on Stackoverflow
Solution 33 - AndroidbazzilView Answer on Stackoverflow
Solution 34 - AndroidMeseret AtsbehaView Answer on Stackoverflow