Mono for Android - Now Available on the Market

After another day of messing around compiling Mono, I finally got it working on Android out of the box. The final hurdle was to tweak a few environment variables at build time to pass the "--dynamic-linker /data/data/com.koushikdutta.mono/ld-linux.so" option into the linker. This way the mono binary will actually find the dynamic linker at a valid location in the Android file system rather than fail with a "not found" error.

The application on the market contains the Mono runtime, which will be unpackaged on first run. It will allow you to run simple command line applications from a tool like Terminal Emulator. Here's some more Mono on Android action, sans Debian. The video shows the simple installation followed by a demonstration of the "Hello World" program that is included with the package.

Note that the application is downloaded, installed, and executed, all without root permissions. There are still some outstanding issues though. If you watched carefully, you will see that I redirected stderr to /dev/null. This is because Mono not running under Debian reports a couple of assertions and errors; once upon starting up and again upon exiting. But they don't really seem to be affect anything from as far as I can tell. It is something I'll need to look into. But first... calling into Mono from Java/Dalvik.

15 comments:

S K said...

Does Mono for Android need a rooted G1? I'm guessing the answer would be a yes.

-SK

Anonymous said...

Well done! Really cool to see something like Mono working on Android! Thanks for your hard work, and I'm looking forward to seeing some really cool things come out of this!

H said...

Really nice and just by looking at your old benchmarks it looks quite promising keep up with your amazing job

Unknown said...

Downloaded and installed the runtime from the market with ease. The included hello world app runs and exits with an exception in a hashtable constructor though. Otherwise very promising. Keep up the awesome work!

Koush said...

Yeah, the hashtable issue is something that is an artifact of not running Mono under the Debian environment. I'll be looking into it, but for now, it seems benign: the application actually works.

Anonymous said...

hi koush,

can you answer my ques pls? does this need a rooted g1? I would think android won't allow calls to native libs otherwise.

-SK

Koush said...

Read the post... no it does not require root. It works on ALL G1s.

pic.micro23 said...

Kush thanks a lot for these. This will open a lot of things.

Is there a way you can provide with a URL for downloading the .apk directly and not market?

DizWARE said...

Is this capable of running code of the sd card because I've been trying with a couple of my old programs and none of them actually start up(couple different outcomes but nothing actually runs) Any solution or tips on how to get this going correctly?

Koush said...

Yeah, it works for me. I should note, I only included mscorlib.dll (ie, System) with this current version. That means only very basic applications will run. It's just a proof of concept release at this point.

Start with something simple first.

Sandy said...

Koush, you are the man! Thanks for doing all the hard work to get this started.

mdi said...

Problems with the Hashtable during initialization typically means a floating point problem (the Hashtable uses floating point code early on).

It is possible that the Android stack uses a different floating point convention that the one used by Debian, and this might be causing the problems.

Koush said...

I discovered that one of the initial assertions are because Android does not define a HOME directory.

So, by default it tries to create the .wapi directory, it fails.

I'll write a couple Hashtable tests to figure out what is going on with the Exception. Can you point me to the code where you think the error is happening?

Thomas Jam Pedersen said...

Thanks Koush. Great achievement!! I did just test it on my brand new HTC Magic.

I installed mono from the market. Worked fine.
Tried the test.exe
On my phone it is in
/data/data/com.koushikdutta.com/assets/bin/
When I try to run it with
./mono test.exe 2>/dev/null
I get this error:
bionic/linker/linker.c:1581| Error: 1120 could not load 'libmono.so'
bionic/linker/linker.c:1641 | Error: failed to link ./mono
bionic/linker/linker.c:1741 | Error: CANNOT LINK EXECUTABLE './mono'
What did I forgot? (or do I have wrong versions)

Anyway are you still working on this os is someone else? Will you release a version with System.Windows.Forms and
System.Drawing ?

As soon as that is availeble we would like to port the Roozzplugin (www.3djam.com) to Android

[Roozzplugin is an alternative to Flash player and Silverlight. But with additional features and it run apps MUCH faster!]

Anonymous said...

I got the same problem, I've the "library libmono.so not found" problem.

If i set LD_LIBRARY_PATH to $LD_LIBRARY_PATH:$PWD, i got a

(reloc_library 1267 cannot localte semget error)

I've just downloaded mono from the market ; where can semget be downloaded from ?