Xamarin Studio is an IDE that allows developers to create iOS, Android and Mac apps using C#. Recently Xamarin released Xamarin Studio 2.0 and along with a free Starter edition. While the Starter edition is very limited it allows developers to see what Xamarin Studio is like and how writing Android apps using C# works. I was hoping to create an iOS app, but it turns out a Mac is still required in order to write iOS apps even with higher editions. In addition the free edition is limited to the use of Xamarin Studio. Higher editions allow you to use Visual Studio.net. There are trials of the higher editions, but require registration with Xamarin. Today I’ll blog a quick walkthrough of the Starter edition of Xamarin Studio installation and creating a basic app for Android on a Windows 7 machine.
Installing Xamarin Studio was very easy. It is one of the easiest installs I have seen for Android development. It tells you exactly what it needs and what it’s going to install. There was no trying to figure out what Java SDK version to install, hunting for prerequisites or messing with paths and workspaces. However I did already have .NET frameworks, Visual Studio 2010, Android SDK and Java 1.7 SDK installed and paths already set up. I am not sure if that made any difference. The installation explained that JDK 1.6 was required and installed it for me. It also seems to handle the installation of Android SDKs or so I thought. More on that below. Installation took about 30 minutes. Much of that time was spent downloading nearly a gig of SDKs and software.
After the installation Xamarin Studio runs pretty fast. If you have used Visual Studio, Eclipse or IntelliJ IDEA you should be comfortable with Xamarin Studio. Here is the project creation window.
Xamarin Studio creates a Solution and Project file that can be opened by Visual Studio, however you will need the Business Edition to be able to work within Visual Studio.
Open up the project and file and you’ll see C# code. The project conveniently contains a basic application that is almost ready to run. The project structure is similar to a typical Android project set up using Eclipse. The Xamarin site says that there is LINQ support and thousands of .NET APIs.
I tried to run it as-is and got an error:
"The targeted Android API Level 4.0.3 cannot be found. Please use the Android AVD manager to install the platforms you’re targeting."
I’m not sure if this was due to my setup, but obviously I was missing something. Going into the AVD manager didn’t help as I did not even have the Android 4.0.3 SDK installed. I guess that during installation Xamarin Studio may not install all the SDKs. That's a good thing since there are a lot of Android SDKs, but I am not sure why it wanted 4.0.3 specifically. I had to go into the SDK manager first to install the Android API 4.0.3 SDK.
After that I was able to create a new virtual device using AVD Manager like the original error message suggested.
Running the project again I ran into the error “Deployment failed because the device does not support the package’s minimum Android version. You can change the minimum Android version in the Android Application section of the Project Options. Deployment failed. Minimum Android version not supported by device.”
That’s a pretty clear error message so I headed to the Android Application section of the Project Options and created a manifest. Looks like a new project does not automatically create a manifest.
I changed the minimum target to a lower version to make sure my virtual device met requirements.
I ran the project again and success!
The entire process from installation to getting the default Android project to run was fairly painless and easy. It took about 1 hour with half of that time spent on the installation.
The project ran fine in the emulator, but I wanted to see how it runs on a device. Creating an Android Package was quick.
If you create the apk in Debug mode the bottom message will say that the shared runtime and platform package will not be included in the resulting package. In Release mode they will. I exported the apk, installed it on a device and it ran fine. I did notice the resulting package came out at around 3MB which is probably due to the shared runtime and platform package. This is huge for a Hello World app, but makes sense considering that the Mono .NET runtime is bundled along with the app. Xamarin says that 2.5 MB of that 3MB is added to the package.
In the short time I used it I thought the studio was nice. Things I liked:
Overall I think Xamarin Studio 2.0 Starter Edition is a good product if you want to evaluate it or if you are a hobbyist programmer that knows C# but not Java and you want to create a very small, simple app. You’ll still have to install Java and the Android SDKs, but Xamarin Studio does make the process easier. For professional developers Xamarin Studio looks like a good option if you want to stay within the Visual Studio environment and use C#, but more importantly if you want to reuse code across across iOS, Android, Windows and Mac. Since many applications are multi-platform this would be a good tool to help manage your code base.