How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.

- 54,432
- 29
- 203
- 199

- 4,884
- 4
- 27
- 33
-
1possible duplicate of [Android: Simulate WiFi in the emulator?](http://stackoverflow.com/questions/1563370/android-simulate-wifi-in-the-emulator) – Sam Jul 20 '15 at 11:00
7 Answers
Wifi is not available on the emulator if you are using below of API level 25.
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
More Information: https://developer.android.com/studio/run/emulator.html#wifi

- 605
- 7
- 15

- 4,884
- 4
- 27
- 33
-
1I want to test VNC server on emulator and vnc server app requires Wifi or USB to get connect to network? then what is the best solution ? – mfq Sep 12 '13 at 14:18
-
1@mfq run on a real device or use an open source VNC app modified not to care. – Chris Stratton Mar 08 '14 at 19:39
-
12dont waste your time @salman khalid? Is that true? As programmers perspective, what I saw is that we need to minimize the cost of buying actual device if it happened. How many devices would we need if we just want to test our app? OMG.... not every programmers are rich as others... come 'on! Let's make the emulator do the works... so we're making another apps... right, imz – gumuruh May 20 '14 at 15:08
-
6"waste time" also came to my attention. That's not nice reply, we waste time on development as needed ;) – Pointer Null May 06 '16 at 11:30
-
3It is available now with Android Studio 3.0 Canary 1 as of today 05/17/2017. – B.K. May 17 '17 at 21:24
-
Is it possible to use the same network as the pc, where the emulated android is running? – Makuna Jul 18 '21 at 00:30
Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.

- 3,579
- 5
- 41
- 62
-
8Agreed. If 3G is emulated then why not WiFi? Even for just the purpose of allowing developers to work with toggling WiFi state. – Kilizo Feb 19 '15 at 22:01
-
1@Kilizo The problem here is the WiFi stack is very heavy to emulate and needs support for bridging the hosts connection (or having a spare WiFi device to use). Even with things like VMWare or VirtualBox getting the virtual machine to correctly use a full WiFi device is a pain. Cellular connectivity is easy to emulate, all it needs to do is connect you to your normal internet, you don't need to worry about local networking or ensuring the Android emulator is able to fully control the network device. – sixones Jan 02 '17 at 12:40
As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25. If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
Added support for Wi-Fi in some system images (currently only API level 25). An access point called "AndroidWifi" is available and Android automatically connects to it. Wi-Fi support can be disabled by running the emulator with the command line parameter -feature -Wifi.
from https://developer.android.com/studio/releases/emulator.html#26-1-3

- 1,987
- 2
- 15
- 23
-
hi, what i will need to do enable wifi feature? because in settings of emulator wifi optionis getting disbled automatically. – NehaK Nov 30 '17 at 09:34
-
I can verify that it works with the Image Android 7.1.1 (Google Apis), API Level 25, ABI x86. The strange thing is that it does not work with newer Images: e.g. API 27, ABI x86 (Here I can enable Wi-Fi, but it will switch back to off automatically) – TmTron Dec 19 '17 at 11:09
-
You are right @TmTron , as of August 2017 the response I got from Google was `You're right about API 26, it's in the works and will be available in the future. As for backporting to earlier versions that's something we would like to do although I can't make any promises as to when that will happen or how far back we will go.` – Eric Labelle Dec 19 '17 at 12:46
-
For the emulator version 27.1.2, Wi-Fi works for API levels 25 and 26, but not 27. – CanC Jan 04 '18 at 12:00
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.

- 1
- 1

- 4,921
- 6
- 53
- 104
-
2Note that most of what makes wifi appear to be "wifi" to an Android app is within the user mode Android runtime. There's a fair chance that all that would need to change is the *reporting*. Though the emulator networking does have some properties more consistent with a 3g provider than a wifi one; specifically a network address translator that does not accept incoming connections other than from the loopback interface of the hosting development machine. Modifying the platform to call it wifi would sort of work, but the only local peer that could connect would be the dev machine. – Chris Stratton Mar 08 '14 at 19:41
The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
You can disable Wi-Fi in the emulator by running the emulator with the command-line parameter -feature -Wifi.
https://developer.android.com/studio/run/emulator.html#wi-fi
What's not supported
The Android Emulator doesn't include virtual hardware for the following:
- Bluetooth
- NFC
- SD card insert/eject
- Device-attached headphones
- USB
The watch emulator for Android Wear doesn't support the Overview (Recent Apps) button, D-pad, and fingerprint sensor.
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
-
12-1 because the screenshot shows the device is connected via 4G not via WiFi, does not answer, solve or provide any helpful information to the question asked. – sixones Dec 27 '16 at 20:07
-
1@sixones That does not necessarily mean it is not connected to WiFi: the 4G is shown for emulation purposes (like, what would your application do if it was at 4G vs 3G) and can be changed through settings. Even if WiFi is shown as _off_ or _not connected_, I am still able to open Google because my computer is connected to WiFi. So although you can view/download websites, you cannot emulate the connection to WiFi for emulation purposes, and thus, for this purpose, you need a real device that is connected to WiFi. – Stardust Dec 30 '16 at 16:35
-
2@Stardust Exactly, so your answer provides nothing to the question asked other than showing you can use a cellular connection. 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. – sixones Jan 02 '17 at 12:36
-
From API 25+ you can use wi-fi https://developer.android.com/studio/run/emulator.html#wi-fi This answer is now outdated – Menuka Ishan Feb 21 '18 at 08:17
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi

- 131
- 1
- 9
If your simulator is not connecting to wifi and your in a mac(I don't know how to add DNS in windows) just go to Network -> advance -> DNS and add 8.8.8.8 and 8.8.4.4 the close the android simulator, open android studio, select the simulator and click on cold reboot then your simulator will be connected to wifi.

- 1
- 1
-
This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33581149) – H4SN Jan 12 '23 at 13:04