News

No Java Required: Write Android Apps in C#

XobotOS is a Xamarin-developed project that translated millions of lines of Java to C#.

Java is the underlying code for the Android OS. But one company has changed all that, ripping out most of the Java and replacing it with C#.

That means .NET developers can code in a familiar language and produce apps that leverage C#'s advantages, including speed increases.

It started as a skunkworks project for Xamarin. Xamarin's claim to fame is Mono, an open-source framework allowing Android and iOS apps to be built using C# running on top of Java. Now, with what the company calls the XobotOS Research Project, the Java layer has been removed via a "machine translation of Android from Java to C#," according to a blog post from Xamarin CTO Miguel de Icaza.

Building XobotOS involved converting more than a million lines of Java code into C#, de Icaza wrote. A tool called Sharpen was used to help in the translation, and the project resulted in an improved version of Sharpen, de Icaza says. Most of Androids layouts and controls, de Icaza says, have been converted, and to demonstrate, the post includes a Java-free screenshot of  XobotOS running on a Linux desktop.

In terms of speed improvements, the blog includes a bar chart of a benchmark from a simple binary tree implementation in Java and C#. The chart shows a huge increase in performance between the two languages.

Xamarin has made XobotOS available on github. de Icaza says that XobotOS won't be "a focus" going forward, as the company wants to put its efforts toward its core products, Mono for Android and MonoTouch.

One other possible benefit of using XobotOS for Android development is that it would eliminate the kind of potential legal entanglements that Google finds itself in with Oracle, the patent-holder for Java. Replacing Java with C# would, of course, inoculate developers from the clutches of Oracle's lawyers.

About the Author

Keith Ward is the editor in chief of Visual Studio Magazine.

comments powered by Disqus

Reader Comments:

Sun, Mar 10, 2013 Yuriy

It is unclear, why start to use C # for Android, if there is Java, and Java is free, but the Mono for Android is costs $ 399 per license. A good programmer can use any language, especially as Java and C # are very similar to each other. So you can pay for your unwillingness to think and learn, but I'm not.

Mon, Sep 17, 2012 80s Rocker

For the person who stated "now they will be in the clutches of Microsoft Lawyers is not true. Unlike Sun with Java, Microsoft submitted C# and the .NET VM for standardization to ECMA and saw those standards graduated all the way to ISO strong patent commitments. The .NET framework is also covered by Microsoft’s legally binding community promise.

Thu, Aug 23, 2012 Htay Aung Mandalay,Myanmar

I want to create android applications using C#.

Thu, Aug 23, 2012 Htay Aung Myanmar

I want to create android applications using C#.

Thu, Aug 9, 2012 Lagos

Nice development, i'll really love 2 learn programing, can someone pls help me.

Mon, Jul 23, 2012 Fred

You wrote, "Java is the underlying code for the Android OS." This is not correct. The Android OS is not written in Java-it's based on the Linux Kernel. You should have written that Java is the programming language used most often to create applications that RUN ON THE ANDROID OS.

Thu, Jul 5, 2012 Mark

Bryant, you might be able to use some of your code base, but not all of your code base on all platforms. Of course the same is true for Java (the language).

Thu, Jul 5, 2012 Mark

I saw Hans reply in the print version of VS.NET. While VS.NET does have some advantages, as a whole, Eclipse is a much better environment. I use both "daily". In fact, that I would have to use VS.NET or Sharp Developer is a major minor in using C# for mobile.

Thu, Jul 5, 2012 Bryant

Guys C# is cross platform. You can use the MS.net framework with C# or the Mono.net framework. Xamarin has paid tools to allow you to develop IOS or Android apps using C#. So you can use your C# code base for apps on Windows, MAC, Linux, IOS, and Android. Yea you have to do your screens on each platform and make tweeks but a lot of underlying logic for most programs can be shared and O by the way C# works with Windows Phone as well. I would call this a major cross platform advantage. You don't have to like C# or .net but it is a contender in the mobile market because of Xamarin. They are banking their company on it.

Mon, Jun 18, 2012 Ryan S Louisville, KY

iOS development already uses Objective-C which is just another variant of C...not that big of a stretch. XCode and the iOS SDK are also free from Apple, so it's not like I have to pay for Visual Studio to develop for iOS. For cross-platform, I think I will stick with HTML5/CSS3/Javascript/XML-WS for now until something better comes along.

Wed, Jun 13, 2012

"Replacing Java with C# would, of course, inoculate developers from the clutches of Oracle's lawyers." - now they will be in the clutches of Microsoft Lawyers.

Sat, Jun 9, 2012 robvon Brisbane, Oz

There is a great opportunity in Mobile apps for .Net developers - those who aren't tied to Windows Mobile. This is another useful piece in an evolving mobile dev world. Note I don't say C# developers - the language choice in .Net is trivial, the dev environment and the framework is everything. Of course I want a full Andriod and IOS dev environment right in VS. Surely thats not too much to ask for ?

Fri, Jun 1, 2012 Sunny Adeshara Ahmedabad

I liked both this article and the technology described in this. I would like to know more about it and the way i can start my development using this and cost of this technology.

Wed, May 30, 2012 Sachin Noida

Hi,good to hear this achievement as I am also a .net developer and market demands android apps but will it be that flexible and platform independent? If yes I will definelty want to work on this technology work to further enhance it.

Sun, May 27, 2012

yeah but it will creates a new OS. not real android. then you must wait until some smartphone maker to adopt this XobotOS

Fri, May 25, 2012 Jeevan singh Banglaore

Is it possible to make this technology platform independent

Thu, May 24, 2012

So lemme get this straight - you think replacing Java/Eclipse with C#/VS is going to work to your advantage? Obviously you haven't worked with both of these languages and environments.

Wed, May 23, 2012 Nomis Armenia

I need write Android Apps in C#

Tue, May 22, 2012 Hans Hollebrandse

Although I think this project is a good development, Java shouldn't be the thing to complain about. If you are a C# developer it is my experience that it is not a big deal to program in Java. The bad thing about the current Android development according my experience with Eclipse and the plug-ins for android, is that it all works buggy. Not only is working in Eclipse a big step back as a develop environment compared to visual studio, also the android emulator behaves often not always as it should, which leaves you often wasting time in finding problems that are untraceable.

Fri, May 18, 2012 Paul Perkins Orlando, FL

While this is a huge technical achievement, I don't see the practical value of what this gets you except the ability to program in c# rather than Java or Objective C. It's not "write once deploy on both platforms"; rather, you still need to worry about Layouts in Android and Storyboards in ios.

Fri, May 18, 2012 Alex C Canada

"but .net isn't platform independent tha's big disadvantage. for this techanology is it possible to solve this issue" - In response to this. Java on Android isn't platform independent either. That is actually the whole reason Google is being sued by Oracle. If Android had remained in compliance with Java, they wouldn't have needed a license and there would be no lawsuit.

Fri, May 18, 2012 Ritesh Pune

but .net isn't platform independent tha's big disadvantage. for this techanology is it possible to solve this issue

Wed, May 16, 2012

You should check out www.vsnomad.com - a VS extension for cross mobile platform development

Tue, May 15, 2012

You don't need a OS ported to C# to write Android app in C#. See Mono for Android.

Add Your Comments Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.