If the emulator is not appear to be connected to the ADB when you Run/Debug your android project on Android Studio. You may need to adjust where the emulator looks for the ADB.
Android Studio Emualtor for Android uses a registry key to identify the base location of the Android SDK.

Run(Win+R) regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools. Modify the Path variable to the path of your Android SDK. D:\Android\Sdk for example.

Notice: If you cannot find the registry key, just create one.

The regedit structor looks like below:

Android Studio support Visual Studio Emulator for Android

Reference: Troubleshoot the Visual Studio Emulator for Android

Answer 1: Force open the wifi

Check this link on stackoverflow for details

Answer 2: Get the mac address by network interface

The below code will help get all mack addresses of the device.


private static String getMacAddress(String interfaceName) { try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface networkInterface = interfaces.nextElement(); if (TextUtils.equals(networkInterface.getName(), interfaceName)) { byte[] bytes = networkInterface.getHardwareAddress(); StringBuilder builder = new StringBuilder(); for (byte b : bytes) { builder.append(String.format("%02X:", b)); } if (builder.length() > 0) { builder.deleteCharAt(builder.length() - 1); } return builder.toString(); } } return "<EMPTY>"; } catch (SocketException e) { Log.e(Constants.TAG, "Get Mac Address Error", e); return "<ERROR>"; } }

Use wlan0 if you want to get the WIFI MAC address, and eth0 if you want to get the ethernet MAC address.


public static String getEthernetMacAddress() { return getMacAddress("eth0"); } public static String getWifiMacAddress() { return getMacAddress("wlan0"); }

Copy the vhd file to a local folder, D:\boot for example.

Run the following command with administrator privilege

rem {current} is an identifier id. This is used to backup the {current} setting, ignore it if you dont want.
rem **strongly recommend**
bcdedit /copy {current} /d "current_backup"

rem set the device(the vhd file)
bcdedit /set {current} device vhd=[d:]\path-to-the-vhd-file
rem bcdedit /set {current} device vhd=[d:]\boot\xxxx.vhd for example.

rem set the osdevice(same path of the device)
bcdedit /set {current} osdevice vhd=[d:]\path-to-the-vhd-file

rem set the default boot item(ignore this if you dont want make the new system as the default one)
bcdedit /set {bootmgr} default {current} //guid.

Reboot the host and enjoy the new system.