June 22, 2018
Hot Topics:

.NET Development (Mono) for Android

  • July 5, 2012
  • By Paul Ferrill
  • Send Email »
  • More Articles »

The recent release of Mono for Android 4.2 brings with it new support for building a user interface (UI) in the form of the Xamarin Designer. Now you can drag and drop UI elements on a XAML design surface right in Visual Studio. There's also a new 3.0 release of MonoDevelop, the open-source integrated development environment (IDE) that runs on Linux, Mac OS X and Windows.

For the purpose of this review we tested using both MonoDevelop and Visual Studio 2010 on 32- and 64-bit Windows 7.


Xamarin has adopted the use of a comprehensive all-in-one installer to make the process easier. Start the process by downloading a small setup.exe file from the Xamarin site, which will determine the components you need to complete the installation. If you had a previous version of Mono Droid installed, you'll need to remove it prior to starting the setup program. While you don't necessarily need to uninstall older versions of the Android SDK, the setup program will download and install another copy, so you might as well remove any old versions to save disk space.

You'll want to make sure you have a minimum of 1 GB of available disk space as the download requires over 600 MB, and those files will expand upon installation. Upon launch, the setup program will check for the proper version of the .Net runtime and pause to download and install it if necessary. Other things the installer will download and install include the latest copy of the Android SDK as you'll need that for testing with a device emulator. The Android SDK depends on the Java Developer Kit (JDK) so if you don't have that installed, the setup program will download and install that as well. Once the entire process completes you'll have the Visual Studio add-in along with the latest version of MonoDevelop.

Building and Testing Android Programs

It will help you get started quicker if you have a little exposure to coding for the Android platform. There are some basic concepts that will be foreign to the average Windows programmer such as activities and intents. The good news is there are lots of examples on the Xamarin site and elsewhere on the Web. You'll find quite a bit of activity on the Mono for Android mailing list and an active IRC channel where you can get your questions answered in real time.

The first time you launch either MonoDevelop (see Figure 1) or Visual Studio (see Figure 2) and choose to create a new project you'll get a ready-to-run sample application you can launch immediately in an emulator. It's basically a simple click-me app where a count is incremented each time the user clicks the button. The user interface has a single button and the code necessary to update the label.


Visual Studio
Visual Studio

The Xamarin designer is new with this release and is the first iteration of a drag-and-drop user interface (UI) builder. Figure 3 shows what you'll see if you double-click on the Main.axml file in the Solution Explorer from Visual Studio. The Toolbox contains all the currently available widgets although some of the items may not be familiar. Figure 4 shows the designer in MonoDevelop. Building a UI for Android consists of choosing a layout and then dragging the widgets onto it. This makes it possible for the Android OS to control the flow when the user changes the orientation of the device.

Main.axml file in the Solution Explorer from Visual Studio
Main.axml file in the Solution Explorer from Visual Studio

The designer in MonoDevelop
The designer in MonoDevelop

Expect to wait a bit the first time you launch the emulator as there are a number of things that must be loaded including the Mono runtime along with the apk for your application. Once that's done you have access to the full debug experience just as you would for any Windows program. Figure 5 shows a breakpoint set at line 28 along with the Locals window where you can see the current value of count is 1. The demo version of Mono for Android will only allow you to deploy to an Emulator (see Figure 6) but is great for checking out the product.

A breakpoint set at line 28 along with the Locals window
A breakpoint set at line 28 along with the Locals window


Final Thoughts

With this release of Mono for Android you truly get an integrated environment including the ability to design your UI from within either MonoDevelop or Visual Studio. This was not possible in previous versions and required you to either build your UI programmatically or use some other external tool. Couple that with integrated debugging, and you have a really powerful tool to build Android apps from virtually any system running Linux, Mac OS X or Windows.

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date