1

Android uses the modified version of JVM known as Android Runtime to execute android apps.

How do games (with Unity 3d) and Apps (Xamarin) written in C# (which require dot Net's Mono framework) run on Android?

The official website of mono says

The Mono runtime has been ported to the Android OS.

What exactly does that mean?

Is Mono Bundled with Android OS?

Is Mono Bundled with each App and Game?

According to this answer on Unity3d forum. It says Mono is similar to Java, in terms of being able to do cross-platform Software development.

This leads back to my initial question,

does android have two runtimes (Mono and ART)?

4

Here is a simplified version of the Mono Architecture:

enter image description here

The heart of this architecture is the Common Language Runtime or CLR. The CLR contains a Just-In-Time compiler (JIT) that converts Common Intermediate Language (IL) into the native code of the platform it is running on. It serves the same purpose as the JIT in Java.

In practice, this means that you just need one C# compiler that will work for any platform. That compiler takes C# as input, and produces IL as its output. There is one CLR written per platform.

When they say that Mono has been ported to Android, what they mostly mean is that a CLR was written for Android. The Class Library (equivalent to the .NET Framework on a Windows system) is written mostly (if not entirely) in C# and IL, and since C# compiles to IL, the Framework should already be compatible.

|improve this answer|||||
  • There are a few classes in the standard library that also need porting to support the new platform, Particularly the Environment and Process classes. There are two main strategies for Android: compile to Android's runtime (Dalvik: en.wikipedia.org/wiki/Dalvik_(software) ) or implement the CLR on top of Dalvik. I assume they did the former. – Berin Loritsch Jan 6 at 21:15
  • Correction, Dalvik is now the Android RunTime (ART), but the same strategies apply. – Berin Loritsch Jan 6 at 21:19
  • @BerinLoritsch: I'm pretty sure they did neither. Mono already runs on Linux, and Android is just Linux. There is no need for a Java implementation of Mono that runs on the ART, nor is there a need for a CIL -> ART cross-compiler, when you can just run the existing Mono runtime natively. Also, unlike Microsoft's CLR, Mono has always supported ahead-of-time native compilation, which is what Xamarin actually uses. – Jörg W Mittag Jan 6 at 21:22
  • 1
    This doesn't answer the main question - if Mono is part of the Android OS or it's bundled in each app. – Rumen Georgiev Jan 8 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.