Developer Console

How to debug Android apps for Windows 11

Behyad Ebadifar Jul 31, 2023
Share:
App performance Appstore on Windows 11 Best practices
Blog_Header_Post_Img

Important: Amazon Appstore on Windows 11 will no longer be supported after March 5, 2025. Read the blog for more information.

 

Existing apps in the Amazon Appstore can now run on Windows 11 through the Windows Subsystem for Android™️ (WSA). This means that millions of PC users on Windows 11 can search for Android apps within the Microsoft store and install them as they can with native Windows apps.

In this tutorial, we’re building upon our existing best practices guide to show how to debug Android mobile apps on the Windows Subsystem for Android using the most popular developer environments (IDEs): Visual Studio, Android Studio, and Unity Editor.

Setting up the development environment

Note: There are Windows 11 minimum device requirements to download WSA and properly test your apps.

First, open the Microsoft Store on a Windows 11 device by selecting Start then typing Microsoft Store. If you’re reading this article from a Windows 11 device, click this shortcut: ms-windows-store://home

Inside the Microsoft store, search for Amazon Appstore and install it. This download will include both WSA and Amazon Appstore in the same installation process. Open Amazon Appstore and sign-in with your existing Amazon developer credentials. If you don’t have an account, you can sign up for free.

Once WSA and Amazon Appstore are installed, you can debug Android apps. Follow these steps:

Setting up developer mode for WSA & Android debugging
 

1. Download and install Android SDK platform tools. Make sure to add the full path of the extracted platform tools to the PATH variable in Windows 11 environment variables: Start > Settings > System > About > Advanced System Settings > Environment Variables

2. Access the WSA settings app: Start > All Apps > Windows Subsystem for AndroidTM.

3. Install the Visual Studio extension “Windows Subsystem for Android Barista” created by Redth (.NET MAUI engineering lead at Microsoft) in order to automatically complete the three remaining steps.

4. Within the WSA settings, toggle the Advanced Settings > Developer mode option in order to turn on developer mode. Additional developer options are available in Manage developer settings but are not required for these setup steps.

Advanced settings on WSA

5. Stay in the WSA settings to select System > Files to access the next menu in order to start the WSA emulator in the background and connect via the Android Debug Bridge (adb).

6. To establish a connection to the emulator, open terminal for Windows: Start > All Apps > Terminal then type in adb connect localhost:58526. Since it is the first time setting up WSA, you need to click Allow access on the Windows security dialog, then check the “Always Allow from this computer” option, then click Allow on the subsequent dialog ADB debugging.

Windows Security Alert
Allow ADB debugging pop up

Configuring your development environment

Visual studio developement environment

  1. Open a .Net MAUI project in Visual Studio. If this is your first time, follow this guide.
  2. Open the devices drop-down and select the emulator “Microsoft Corporation Subsystem for Android”,
  3. Run the project to view your app in WSA emulator.
  4. Application debug logs are available with in the Debug view of the IDE. ADB logs can be accessed either by adb logcat command from a terminal window or can be viewed in line with the IDE via View > Pads > Device Log

Android Studio development environment

  1. Open an Android project on Android Studio
  2. Open the devices drop-down and select the emulator “Microsoft Corporation Subsystem for Android”. WSA emulator appears under the physical devices section.
  3. Run the project to view your app in WSA emulator.

Unity Hub development environment

  1. Open a Unity project in Unity Hub. If this is your first time, follow this guide.
  2. Open Build Settings: File > Build Settings and chose Android Platform.
  3. Hit the Refresh button next to Run Device drop-down for Unity to detect “Windows Subsystem for Android”. You may need to do this several times for the connection to complete. If Unity is unable to detect, add it manually by selecting “<Enter IP>” and typing localhost:58526.
  4. Select Windows Subsystem for Android emulator and click on Build And Run in order to start debugging.
  5. If you get a build error about OpenGL support, open the Build settings again and chose Player Settings in order to remove and add Open GL3 Graphics API. This step will reset the configuration.
  6. The standard app debug messages are visible in the console view, and you can install the “adb logcat package” if you want to view device logs within the Unity editor.

Monitoring and profiling tools

Before you go to publish your app for Amazon Appstore, it is important to review the pre-submission checklist and evaluate any memory leaks, performance bottlenecks, or possible app crashes. Each of the IDEs described in this article have a collection of performance analysis tools to provide all the necessary app metrics for troubleshooting and resolving memory issues.

Here is a breakdown of monitoring and profiling tools for each of the IDEs we covered above:

Visual Studio
Visual studio offers a range of monitoring tools that are baked into the IDE. Tools such as CPU Usage and Memory Usage are available within the diagnostics tools window of the IDE. Read the docs on profiling tools for Visual Studio to learn more.

Visual Studio Enterprise edition provides access to Xamarin Profiler that can be used to profile mobile apps developed using Xamarin framework. Read the docs to learn more.

Android Studio

Mobile apps developed using Android Studio can use built-in profiling tools to monitor CPU, Memory, Energy, GPU, and Frame rate. Follow the Android docs to learn how to use these profiler tools.

Unity Editor
Apps built with Unity editor can use the Unity profiler to analyze gaming assets apart from the standard CPU, Memory, and network diagnostics. In addition, Unity profiler also provides monitoring GPU usage, Frame rate, and Scene management. Read the Unity Profiler docs to learn more.

Conclusion

By following these instructions and our best practices docs, we hope you are able to streamline your Android to Windows 11 development process and quickly identify and fix issues for a smooth publishing process for Amazon Appstore and WSA.

Related resources

Related articles

Sign up for our newsletter

Get the latest developer news, product releases, tutorials, and more.