Did you know you can deploy and debug your Android projects from Visual Studio 2022 (17.3+) to WSA (Windows Subsystem for Android)? This is a quick post to show you how to have your WSA appear in the list of target Android devices in Visual Studio.
First, make sure you have WSA installed and enabled, find the instructions here Windows Subsystem for Android™️ | Microsoft Docs. Once it is installed, start the Amazon App Store app to ensure WSA has been started.
Open the Windows Subsystem for Android™ Settings app (this gets installed with WSA) and make sure the Developer > Developer Mode setting is enabled. After it is enabled, you should now see an loopback IP address (
127.0.0.1) and a port number (
With WSA setup and running you can now deploy from Visual Studio 2022. The first step is in Visual Studio, expand the Tools > Android menu and select
Android Adb Command Prompt menu item.
When the ADB command prompt window is opened, you can connect ADB to WSA using the ‘connect’ command and IP:port number for WSA. Here is the full command:
adb connect 127.0.0.1:58526and here’s a screenshot of a successful connection:
Finally, in your MAUI project; make sure the target framework is set to
net6.0-android and you should find WSA listed under the Android Local Devices menu.
Here’s what it looks like after I deployed an early prototype of my current Microsoft Store app Hacked? as a .NET MAUI Android app!
Troubleshooting Tip 1 – Missing ‘Android Local Devices’
Problem: If you do not see Android Local Devices in the menu, then it means your WSA is probably put back to sleep by Windows because it wasn’t being used.
Solution 1: Just open any Android app, like the Amazon App Store, to start WSA again (you can keep that app open to prevent WSA from going back to sleep). Note: After it has been stopped and started, you’ll need to reconnect ADB again.
Solution 2: Another option is to tell Windows 11 to never put WSA to sleep. It will start up with Windows and always use system resources. Open the Windows Subsystem for Android Settings app and change the System > Subsystem Resources setting to
Continuous (see screenshot)
Troubleshooting Tip 2 – No Internet in WSA
Problem: If you do not have any internet in your WSA apps, check to see if you have a VPN active. It is known that Cisco AnyConnnect’s network adapter can interfere if the split tunnel routes traffic with the same IP as the WSA vm.
- Solution 1: If you disconnect the VPN, the internet will work in WSA again.
- Solution 2: There is a semi-permanent solution for this by changing the AnyConnect network adapter to have a higher
InterfaceMetricvalue than the WSA Hyper-V adapter one has. Here’s a screenshot of the two PowerShell commands I used to do that: