Debug on Device

This article explains how to debug a Xamarin.Android application on a device.

Overview

It is possible to debug a Xamarin.Android on an Android device using either Xamarin Studio or Visual Studio. Before debugging can occur on a device, it must be setup for deployment and connected to your PC or Mac.

Debug Application

Once your device is connected to your machine, debugging a Xamarin.Android application is done in the same way as any other Xamarin product.

First, make sure the debug configuration has been set, to allow you access to the debug tools:

Next, set your breakpoint as shown below:

Visual Studio:

Xamarin Studio:

Once you have set the breakpoint, start debugging your application by pressing Cmd-Enter in Xamarin Studio on OS X or F5 in Visual Studio. When you do so, you may be prompted to choose the device to debug with, as shown in the following screenshot from Visual Studio:

Once the device has been selected, Xamarin.Android will connect to the device, deploy the application, and then run it. When the breakpoint is reached, the debugger will stop the application, allowing you to debug the application just like you would any other C# application. The screenshots below show the inspection of object values:

Visual Studio:

Xamarin Studio:

Summary

In this document we discussed how to debug a Xamarin.Android application by setting a breakpoint and selecting the target device.