2

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)?

0

1 Answer 1

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.

4
  • 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. Jan 6, 2020 at 21:15
  • Correction, Dalvik is now the Android RunTime (ART), but the same strategies apply. Jan 6, 2020 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. Jan 6, 2020 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. Jan 8, 2020 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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