Debugging Android Applications with the Windows Subsystem for Android

As part of the announcement of Windows 11 earlier this year, Microsoft touted the ability to run Android applications on Windows. Recently this feature was made available via the Beta channel of the Windows Insider program. In this post I’m going to step through setting up the Windows Subsystem for Android (WSA), in order to install and run applications from the Amazon Appstore, and then look at how to debug applications using the WSA. Whether you build cross platform application using Uno Platform, XamarinForms, .NET Maui or any other technology, you can connect to the Windows Subsystem for Android to run and debug your applications during development.

Before we get started a couple of points:

Installing the Windows Subsystem for Android

The Windows Subsystem for Android is actually installed as a required component when you install the Amazon Appstore, which will appear in the Microsoft store if you’re running a build of Windows that matches the requirements (here’s a direct link to the Amazon Appstore).

The installation process for the Amazon Appstore has been well curated to walk users through installing the Windows Subsystem for Android.

The Set up process prompts the user to Download the Windows Subsystem for Android.

After the Windows Subsystem for Android has been installed, you may be required to Restart your computer. Following a restart, the Windows Subsystem for Android will complete the installation.

The Amazon Appstore will then prompt you to sign in. At this stage you’ll need to sign in with an Amazon account that is based in a supported country (I think this is limited to the US at the moment).

After signing in, the catalog of applications can be browsed.

I did notice that there are some visual glitches when browsing the Amazon Appstore. I don’t know whether this is because it’s web content, or just an incompatibility issue with Android apps running on the Windows Subsystem for Android.

Selecting an app, you see a typical downloading/installing interface.

Following installation, the application can be launched directly from the Amazon Appstore

I was surprised at how well the applications I tried worked. For example, the BBC Sounds application scaled well as I resized the Window and even the sound quality appeared to be reasonable.

Debugging Applications with the Windows Subsystem for Android.

The documentation by Microsoft covers how to connect to the Windows Subsystem for Android using ADB in order to then debug applications. I’m going to run quickly through the experience I had. To connect to WSA using ADB you can either to 127.0.0.1:58526, or you can look up the IP address of the WSA using the Windows Subsystem for Android settings application (just launch the Windows Subsystem for Android application from the Windows Start menu or search).

Initially when you attempt to connect you may see a message saying either that the target machine isn’t available, or that it has actively refused the connection.

There are two things to check:

  • Make sure the Windows Subsystem for Android is actually running in the background. The easiest way to do this is to simply launch an application from the Amazon Appstore.
  • Make sure that you’ve enabled Developer mode in the Windows Subsystem for Android settings application.

When enabling Developer mode you’ll be prompted to adjust the firewall settings to allow connections.

Now, you should be all good, to connect to the Windows Subsystem for Android using ADB.

As soon as you’ve connected using ADB, the “Microsoft Corporation Subsystem for Android (TM)” device should become available for debugging in whatever IDE/tools you’re using. In this example I’m using a basic dotnet Maui application but this would also work for a regular Xamarin Android, Xamarin Forms, or Uno Platform application.

To run the dotnet Maui application, simply select the framework (with VS2022 dotnet Maui uses a single project for all targets) and hit F5 to run the application. The following images show the Android version of the dotnet Maui application running on the Windows Subsystem for Android, and then the corresponding Windows version. The only difference between the two is the presence of the back button in the title bar of the Android version (required since Android has a mandatory back button).

You’ll also notice that the Android application gets added to the list of applications installed on Windows. In fact, it’s hard to tell from the applications list that the application is indeed an Android application.

That is, unless you click on App settings, which brings up the familiar Android application settings interface.

In closing out this post, I want to point out that just because this is a Microsoft feature, the running of Android applications is by no means limited to applications built using Microsoft technology. This also extends to the ability to debug applications. The following image shows a Flutter Android application running on the Windows Subsystem for Android – this is not the Windows build of the Flutter application, it’s the Android application that is running, with the debugger attached. This is all possible after connecting to the Windows Subsystem for Android using ADB.

For app developers who already have an Android application, you can start testing your applications on Windows today and submit them to the Amazon Appstore in anticipation of the Windows Subsystem for Android becoming widely available to all Windows developers.

One hope I have is that Microsoft is able to integrate the Amazon Appstore listings into the Microsoft Store – having to install the Amazon Appstore, and then use the Amazon Appstore to find, download and install applications is a truly fragmented experience.