Reputation: 3321
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.
Upvotes: 252
Views: 255733
Reputation: 2596
It doesn't matter if you are using Windows or MAC, you do not have to change your local PC network settings!
The older answers to this problem no longer work after 2020 (Using Android Studio 4.1.2 or newer). 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:
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.
Upvotes: 239
Reputation: 321
My case, emulator android 11. If you use WARP 1.1.1.1 on Mac, try turn it on, it would help.
Upvotes: 1
Reputation: 4778
On Windows :
After testing some solutions, I worked on my case by clicking the down arrow on the AVD, option "Cold Boot Now". after booting, Android has access to the internet.
Upvotes: 8
Reputation: 129
After doing these steps make sure you don't have any VPN software active.
Open Network and Sharing Center
Right Click on current internet connection
Select Properties
Double Click on Internet Protocol Version 4 (TCP/IPv4)
Select Use the following DNS server address
Set the Preferred and Alternate DNS server
Prefered DNS Server : 8.8.8.8
Alternate DNS Server : 8.8.4.4
Click on OK
Restart Android AVD
Upvotes: 3
Reputation: 650
I tried all of these solutions with no results. I am using Windows 10 OS
What finally worked for me was:
1. Closing all instances of AVD devices
2. Navigating to:
C:\Users\userName\AppData\Local\Android\Sdk\emulator
3. Then entering the following command:
.\emulator.exe -avd avd_device_name -dns-server 8.8.8.8
Upvotes: 5
Reputation: 410
There are 2 ways to fix this bug.
Upvotes: 6
Reputation: 3102
My situation is I have internet connection in browser but not in Google map/Google play store. So I try to disable my VPN. Then it solve this issue and my emulator network is active
Upvotes: 1
Reputation: 9
Try disabling your antivirus and then restart your emulator that helped in my case.
Upvotes: 0
Reputation: 31
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.
Upvotes: 1
Reputation: 638
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.
Upvotes: 1
Reputation: 390
Under Extended Controls ( which can be enabled by pressing the more button (3 dots ... ) at bottom.
Then under Proxy tab, Select no proxy.
Upvotes: 2
Reputation: 86
Solution for issue on Apple M1:
Here is the link for the android studio releases list: https://developer.android.com/studio/archive
(Worked for me)
Upvotes: 3
Reputation: 290
This may not solve everyone's problem but I disconnected my wifi and used the Ethernet connection. This resolved my issue.
Upvotes: 0
Reputation: 3975
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
Step 2.
Close Wifi on emulator.
Then LTE can work
Step 3. (Optional)
By the way, My DNS setting of my mac Network is
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.
Upvotes: 21
Reputation: 471
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.
Upvotes: 1
Reputation: 4138
If anyone quick fix:
Step 1: Go to AVD Manager
Step 2: Stop the device
Step 3: Run Android Studio project
Upvotes: 3
Reputation: 41
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.
Upvotes: 1
Reputation: 59
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
Upvotes: 5
Reputation: 3862
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
Upvotes: 2
Reputation: 496
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.
Upvotes: 6
Reputation: 2352
On macOS:
Upvotes: 30
Reputation: 405
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.
Upvotes: 14
Reputation: 6587
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:
Upvotes: 218
Reputation: 1302
Solution for Windows:
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.
Upvotes: 22
Reputation: 6480
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.
Here I show for setting v4 IP steps
Note : If VPN is enabled then it will not work need to disconnect your VPN
Upvotes: 9
Reputation: 31841
Stated below are the solutions for Windows and Mac, but similar solutions will work on any OS:
On Windows
Set the Preferred and Alternate DNS servers as (Screenshot below) :
8.8.8.8
8.8.4.4
On Mac
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:
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.
Upvotes: 334
Reputation: 61
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.
Upvotes: 6
Reputation: 637
I was having the same issue and following the below steps resolved it.
Steps:
Upvotes: 14