Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Android Emulator Wifi Connected with No Internet

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.

like image 659
Vikram Mahishi Avatar asked Jun 03 '18 20:06

Vikram Mahishi


People also ask

How do I enable internet on Android emulator?

Go to your Android\Sdk\emulator folder and open command prompt. Type emulator -list-avds to see available emulator names. Type emulator -avd name-of-your-device -netdelay none -netspeed full -dns-server 8.8. 8.8 command and press enter.

Does Android emulator support Wi-Fi?

The Android UI is pretty simple, if your connected to Wifi it shows in the notification bar, it can also show your cellular connectivity at the same time depending on what has happened. All you have shown is that you can use the emulator on a wifi connected host machine, which is not what this question was asking.

Do emulators work without internet?

No. Not at all. Unless you are running an app that needs internet.


2 Answers

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 
  2. 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.

like image 186
Raman Sahasi Avatar answered Oct 03 '22 04:10

Raman Sahasi


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.
like image 44
Juangui Jordán Avatar answered Oct 03 '22 04:10

Juangui Jordán