Creating native iOS and Android apps in Visual Studio using C#

Lets go Mobile!

One of my interests in software development is in mobile devices, websites and applications. I have blogged about it in several topics. But this was all about mobile websites and optimizing your website for mobile devices.

In my search for new and interesting things, I ended up with an idea to develop a native app. Because I don’t own any apple device (proud of that!), I wanted to develop a native Android application.

A good starting point for creating Android apps is, of course, the Android docs. But there is one disadvantage, it is Java. I don’t really hate Java, but it is just not for me. I don’t have an IDE set up for Java, I don’t know the language as well as c#, so I didn’t really feel like working with c#.

Xamarin

That is when I found Xamarin. It was actually Scott Hanselman who blogged about it. If you don’t know who Scott Hanselman is, please read his blog! Even better, if you have the change, go and see him when he is speaking.

Xamarin lets you develop native apps in Visual Studio using c#. Everything is strongly typed and works how you expect it to work. The debugger starts the Android emulator and lets you easily test your application.

Just one bad thing about Xamarin, the pricing! It is very expensive, but you can download a 30 day trial.

Setting up your environment

Before you can use Xamarin, you need to set up your environment. I assume you already have Visual Studio installed.

To start using Xamarin, you need to install the following:

First install the Java JDK.  In my case I needed to updated the PATH environment variable (Control Panel -> System -> Advanced System Settings -> Environment Variables) and add the bin folder to this variable. In my case C:\Program Files\Java\jdk1.7.0_51\bin.

After that, unzip theAndroid SDK to a location of choice. Run the SDK Manager as administrator. And install all desired packages.
The installed APIs can be selected from within Visual Studio in the Project Properties.

Now this is done, we can install Xamarin. When this the installation is completed, start Visual Studio and configure it. Go to tools -> options and select Xamarin. In the Android Settings tab Select the Android SDK location. And that’s it. Ready to go!

Project Settings

When you open Visual Studio and select new project, you will find a new option in templates, Android. By selecting this option, you will find several Android applications. Most of it just change the API level.

This can simply be changed in the properties window of the Project.

android-properties
Updating the “Minimum Android to target” property will change the targetted API level. My suggestion: keep the API level as low as possible.  This enhances accesibility.

The Xamarin docs are a good place to start. They have a lot of good tutorials to get started. In my next posts, I will post about native apps and code!

The following two tabs change content below.
I'm a software developer from Utrecht. Interested in DDD, continuous delivery, new technologies & frameworks.

Latest posts by Vincent Keizer (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *