Practical .NET

Debugging Xamarin Android Apps

When it comes time to debug your Xamarin Android apps, you have several options. You can debug your application in an emulator or on your own smartphone. Your phone can be connected to your computer with either a USB cable or through WiFi.

This is a report on my experience and what has, in the end, worked for me. This is an area, however, where new releases (and whole new software packages) are coming out weekly. So, be aware: The recommendations in this column may already be out of date.

The Pain of Emulators
One option is to use the emulators delivered with the Android SDK. My experience with them has been that they are both slow and buggy.

You can speed them up either by downloading and installing Intel's Hardware Accelerated eXecution Manager (HAXM) or turning on Windows Hyper-V virtualization platform (assuming your processor and version of Windows support either). You'll need to pick one or the other but my experience has been that, with either, while the emulators ran faster, they were still slower than I was willing to live with ... and still buggy.

You're welcome to try them out, however. While HAXM is a download, Hyper-V comes with Windows but is turned off by default. To enable Hyper-V, you first need to type "Turn Windows Features On or Off" in the Start menu search bar to get to the Windows Features dialog. In that dialog, you need to check off both the entry for Hyper-V and (further down in the dialog) the entry for Windows Hypervisor Platform. With those two features enabled, your emulators should run in their own virtual machines (at least, that was my experience with Visual Studio 2017).

Both Google and Microsoft have released new emulators this summer (2018) but after much upgrading and fiddling around, I wasn't able to get them to work. I'm told that isn't unusual but your mileage may vary, of course.

Debugging on Your Own Hardware
As a result, my experience has been that it's just as easy to debug on a physical smartphone as on an emulator. To enable that, on the smartphone you want to use as your testbed, you must turn on developer mode (I have a link that describes how to turn that on coming up -- be patient). Turning on Developer mode gives you, in your phone's Settings screen, a new Developer's Settings option. In there, you must turn on USB debugging.

You can use Android Live Player to debug applications on your Android phone without having to plug your phone into your computer. Live Player does have limitations, however: As soon as I add SQLite to an application, for example, Live Player stops working (that behavior may have changed by the time you read this, of course).

What Works for Me
Because of that limitation, I use a USB connection between my phone and my development computer to handle debugging. To get that to work, it's probably not enough to just turn on Developer's Mode on your smartphone and plug your phone into your computer, at least the first time you try debugging.

To begin with, you should follow these steps (which include turning on Developer Mode on your Android phone). However, I found I also had to find my phone in Windows Device Manager (in Windows 10, your phone is listed under Portable Devices), right-click on it, and select the Update Driver option. I didn't actually need to replace my driver but my computer steadfastly ignored my phone until did this.

There is a WiFi option you can use here instead of a USB cable but, because I'm often at client's sites and my phone's IP address changes, I don't use it.

If you don't like having to constantly reach for your phone to see what's happening on its screen, take a look at Vysor. Vysor both mirrors your Android phone screen and lets you control it from your laptop screen. Vysor has an entry-level version for free but it's relatively cheap to own the full version outright. It also has a WiFi option ... which I don't use (see above).

I don't want to leave you with the impression that debugging Xamarin Android applications is "neither easy nor fun" -- it's actually relatively painless ... once you've got the right setup, of course. Getting to that part, however, can be "neither easy nor fun."

About the Author

Peter Vogel is a system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at

comments powered by Disqus


  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube