Ever wondered how to debug your Xamarin Android applications on an Android device from Visual Studio; say example a Nexus 7 device?  Well, if you have then read on!

The Problem

Let’s start this scenario by creating a new Xamarin.Forms application in Visual Studio 2013.

new xamarin.forms project

After the application is created, go ahead and set the Android project as the default project in the solution explorer.

vs solution explorer set default project

Now, let’s just go right ahead and try to debug our Android app using the Visual Studio debugger.

debug options without nexus 7 option

As you can see, we only have an option for the crappy built-in Android emulators.  Not what I want to use to debug.  I would rather use a real device, so I can see the application working on a real device.  I just so happen to have a Nexus 7 that I would like to use.  So my first step was to plug my Nexus 7 into my computer using a USB cable, but unfortunately that doesn’t seem to work.  I need to do more.  A lot more.

Prepare the Nexus 7 Device

The first step we need to do is prepare our Nexus 7 device so that we can use it as a debugging target.  Start by going to your Nexus 7 “”Settings”.

Nexus 7 settings

Next scroll down until you see “Developer Options”.

Nexus 7 developer options

No Developer Options?

If you don’t have the Developer Options item available (like in the screenshot below), that means your device is not set up to be a developer device.  Luckily, that’s an easy (yet very hidden) thing to enable.  All you have to do is go into the About Tablet and find the Build Number.

Nexus 7 about tablet

Nexus 7 build number

Once you have found the Build Number, simply tap on it 7 times.  Yes… that’s right, just tap on that baby about 7 times.

Nexus 7 developer

AND VIOLA!  You are now a developer.  Now, go back and you will have the Developer Options available.

Nexus 7 USB debugging

You will see an option called “USB Debugging” that is unchecked.  CHECK IT!  You’re going to get the following prompt.

Nexus 7 allow USB debugging

You’re most likely going to say OK, since you want to debug on this device.  But, I guess you can always change your mind last minute.

Setup Windows

Now that the Nexus 7 has been setup to allow USB debugging, we need to get our Windows machine setup to that it will support USB debugging to the Nexus 7 device.  First, you need to download the Google USB Driver for Windows.

Download Google USB Driver

The easiest way is to click the big blue button on the right of the screen.  Download the driver, save it to your computer somewhere, and unzip it.  Once you have downloaded the driver, we need to install it.  Right-click “This PC” and select “Manage” to open up the Computer Management console.  Go to the “Device Manager” and find the Nexus 7 device.  Notice the yellow warning sign icon?  Yeah, we’ll be fixing that.

manager computer

Right-click the Nexus 7 device and select “Update Driver Software”.

update driver software

When you get the update prompt, make sure you choose the “Browse my computer for driver software” option.  This will take you to another prompt that will ask you where to find the drivers.

browser for google usb drivers

Browse to the location where you saved and unzipped your Google USB Drivers.  Then hit next.  You will be prompted again just to make sure you want to install this driver software.

confirm google usb driver install

Click install, and wait.  When the installation has finished, you will see the following prompt.

google usb driver install complete

Now that your Google USB Drivers are installed.  Look back at your Nexus 7 device.  You are being prompted to allow your computer to debug to your Nexus 7 device through USB.  Of course you want to accept this by hitting the OK button.

Nexus 7 Allow USB debugging confirm

Debug in Visual Studio

Go back into Visual Studio 2013 and take another look at your debugging options.

Nexus 7 listed as Visual Studio debug option

That’s right, your Nexus 7 is now listed as a device that you can deploy and debug your Xamarin Forms Android application.  Click the “Google Nexus 7” debug button, or press F5, and take a look at your device.

Nexus 7 debugging Android app from Visual Studio

You know what that is?  Oh yeah you do!  That’s success!

I hope you find this post useful, and as always, feel free contact me on my blog, connect with me on Twitter (@brianlagunas), or leave a comment below for any questions or comments you may have.

Brian Lagunas

View all posts

3 comments

Follow Me

Follow me on Twitter, subscribe to my YouTube channel, and watch me stream live on Twitch.