110

Is it possible to write an android app using C#? Is there an API or something? Is it free for personal and commercial development?

What do I need to install to have android project template in my Visual Studio?

Braiam
  • 1
  • 11
  • 47
  • 78
CoolArchTek
  • 3,729
  • 12
  • 47
  • 76
  • not sure about any way that C# can be used but you can try HTML5.....(but have some limitation) – Dheeresh Singh Jun 09 '12 at 15:14
  • C# is more similar to objective C than java. iPhone's use the former, Android uses the latter, and so it would make more sense to try out iPhone development than Android development if you already know C#. – Todd Davies Jun 09 '12 at 15:28
  • 85
    @ToddDavies I would disagree entirely and say Java and C# are the most similiar languages. Infact I would say Objective C does not reflect C# at all. – Darren Jun 10 '12 at 17:21
  • 1
    Well, each to his own opinion, but I'm sure that Java is to Objective C as I am to my most hated fifth removed cousin :P – Todd Davies Jun 13 '12 at 17:06
  • 1
    +1 @DarrenDavies The Mono bindings for iOS struggle to represent their Objective-C equivalents in some places (e.g. protocols) but they are straightforwardly 1-1 against Android. – Danyal Aytekin Jan 30 '13 at 15:14

7 Answers7

82

Having used Mono, I would NOT recommend it. The Mono runtime is bundled with your app, so your apk ends up being bloated at more than 6MB. A better programming solution for C# would be dot42. Both Mono and dot42 are licensed products.

Personally, I would recommend using Java with the IntelliJ IDEA dev environment. I say this for 3 reasons:

  1. There is so much Java code out there for Android already; do yourself a favour and don't re-invent the wheel.
  2. IDEA is similar enough to Visual Studio as to be a cinch to learn; it is made by JetBrains and the intelli-sense is better than VS.
  3. IDEA is free.

I have been a C# programmer for 12 years and started developing for Android with C# but ended up jumping ship and going the Java route. The languages are so similar you really won't notice much of a learning curve.

P.S. If you want to use LINQ, serialization and other handy features that are native to C# then you just need to look for the equivalent java library.

darksider474
  • 951
  • 8
  • 6
64

You could use Mono for Android:

http://xamarin.com/monoforandroid

An alternative is dot42:

http://www.dot42.com/

dot42 provides a free community licence as well as a professional licence for $399.

Darren
  • 68,902
  • 24
  • 138
  • 144
  • Please take a look at the comment I added to Seva Alekseyev's reply. – CoolArchTek Jun 09 '12 at 15:17
  • @CoolArchTek - you can download the evauluation for free, however Mono for Android Professional is $399 and Enterprise is $999. https://store.xamarin.com/ – Darren Jun 09 '12 at 15:19
  • 13
    To write a few apps for yourself and your mates $399 is exceedingly prohibitive. I would wish there was something 'in between'. Considering that Android+Eclipse is FREE and Visual Studio Express is FREE, xamarin are missing out on a lot, simply because of their prices – cmroanirgo Dec 17 '12 at 21:51
  • 1
    @cmroanirgo Xamarin now supports a subscription based model with a free option - you no longer need to buy Mono for Android. – James Oct 18 '13 at 14:08
  • @james that's only true for small apps which don't P/Invoke third-party libraries: https://store.xamarin.com/ – Redoman Nov 04 '13 at 22:11
  • @jj_ yeah I know, I wasn't going into the details of the free subscription the point I was making was you *can* release apps without having to purchase a license (where as before you did) – James Nov 05 '13 at 00:01
  • too expensive to be useful for individual developers. I personally am gonna try dot42 first and if that doesn't work use native Java. – Sandeep Singh Rawat Jan 03 '14 at 14:44
  • 4
    [http://www.dot42.com/](http://www.dot42.com/) has this on their site `dot42 has been discontinued and is no longer supported. All sources are availabe on GitHub. The latest build is available as a binary setup.` as of 5/29/2015. They did have a [source download](http://www.dot42.com/download/Dot42AndroidSetup.exe) and a [GitHub](https://github.com/dot42). – JabberwockyDecompiler May 30 '15 at 05:04
20

Here is a new one (Note: in Tech Preview stage): http://www.dot42.com

It is basically a Visual Studio add-in that lets you compile your C# code directly to DEX code. This means there is no run-time requirement such as Mono.

Disclosure: I work for this company


UPDATE: all sources are now on https://github.com/dot42

Frank Rem
  • 3,632
  • 2
  • 25
  • 37
  • 6
    I don't think this is the right place to discuss pricing, but make sure to compare the correct licenses. I do want to note that dot42 comes with a free Community License for non-commercial use. – Frank Rem Jan 29 '13 at 08:27
  • 4
    Frank, you are absolutely right and I must admit that I did not notice the community license. – Dave81 Jan 31 '13 at 08:40
  • 1
    nice. any comments if you will ever consider creating c code for ios? – citykid Feb 21 '13 at 15:23
  • @thomas You mean compile C# to iOS executables? If so, yes it is on the roadmap but it this point we can not give any realistic date. We have our hands full with all the feedback coming from the Android community since we launched. We first want to make sure we get this part right. – Frank Rem Feb 22 '13 at 09:58
  • @FrankRem it's a shame your licensing doesn't make a difference between a commercial hobbyist and a sole developer from a large business. – Den May 03 '13 at 14:23
  • @FrankRem are there any limitations at all, like http://docs.xamarin.com/guides/ios/advanced_topics/limitations – Den May 03 '13 at 14:24
  • @Den re license model. although you could argue whether a commercial hobbyist is a contradiction in terms, I understand your point. we prefer to keep our license model simple, both for you and us. we have just 2 types: community (free) and professional ($). we can only hope it strikes a good balance. – Frank Rem May 06 '13 at 13:42
  • 2
    This is awesome! Are there any plans for putting in a UI designer? Or can I use another tool to do this? Excellent work ! – Piotr Kula Sep 11 '13 at 20:40
  • 2
    Actually, there are no such plans at the moment. You can use Android Studio for designing the UI. You can then import those resources in Visual Studio. – Frank Rem Sep 16 '13 at 12:48
8

Mono Touch is the answer.

http://xamarin.com/monotouch

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • Is it free for commercial development? I want to develop an app that is for a company (their users). – CoolArchTek Jun 09 '12 at 15:16
  • They have it so that you can use lots of it for free. But there is a licence fee of some sort iirc – FoamyGuy Jun 09 '12 at 15:18
  • Is Mono is the only way? Are there any opensource options avail? – CoolArchTek Jun 11 '12 at 13:52
  • 5
    Mono is open source IIRC. Also, do you realize the effort of porting the whole C# (CLR) runtime to a different platform, with little support from Microsoft? It's a miracle even Mono exists. Google and MSFT are direct competitors in the mobile space, C# is a MSFT-backed technology. Go figure. – Seva Alekseyev Jun 11 '12 at 15:04
6

I have used the Unity 3D game engine for developing games for the PC and mobile phone. We use C# in this development.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Sonu
  • 458
  • 5
  • 13
5

You should try something running Mono (its compatible with .NET).

For game development, I recommend unity: http://unity3d.com/

for general aplications: http://xamarin.com/monoforandroid

roim
  • 4,780
  • 2
  • 27
  • 35
4

There are indeed C# compilers for Android available. Even though I prefer developing Android Apps in Java, I can recommend MonoForAndroid. You find more information on http://xamarin.com/monoforandroid

libjup
  • 4,019
  • 2
  • 18
  • 23