Mono for Android - First Update

I mentioned in my previous post that Mono was displaying assertions and exceptions on run when not being under the Debian environment. I have resolved these issues by tweaking a few variables on configure, and one by patching mono/metadata/security.c.

I am also now building Mono from the trunk (instead of 2.0.1) and using eglib instead of glib. Here's what I run to build Mono (still done on the emulator, under Debian):

export 'CFLAGS=-DARM_FPU_NONE -DPLATFORM_ANDROID -Wl,-rpath,.,-rpath,/data/data/com.koushikdutta.mono/assets/lib,--dynamic-linker,/data/data/com.koushikdutta.mono/assets/lib/ld-linux.so.3'

export CPPFLAGS=$CFLAGS

export 'LDFLAGS=-Wl,-rpath,.,-rpath,/data/data/com.koushikdutta.mono/assets/lib,--dynamic-linker,/data/data/com.koushikdutta.mono/assets/lib/ld-linux.so.3'

./configure --disable-mcs-build --with-tls=pthread --disable-shared-handles --with-static_mono=no --with-glib=embedded --prefix=/data/data/com.koushikdutta.mono/assets --exec-prefix=/data/data/com.koushikdutta.mono/assets

make

However, "make" fails while building docs. That is ignorable though. I actually comment out docs in my Makefile, as I haven't looked into how to disable it during configure.

With this setup, the base mono installation directory is /data/data/com.koushikdutta.mono/assets (instead of /usr/local). The binaries, libraries, and assemblies should be placed in their usual relative locations: ie, mono binary should be in bin, the libraries in lib, etc.

Now, if you were to run "./mono test.exe" from a terminal, you will see a lengthy assertion. This is because Mono is failing to find the user's home directory, because Android does not set that environment variable. And thus Mono doesn't have a valid location for the ~/.wapi/ directory. The ".wapi" directory is used by Mono for some transient files and communication (from what I understand). For example, if you were to run Mono under Terminal Emulator, HOME needs to be a location the Terminal emulator process and uid has full read/write permissions: /data/data/com.android.term:

export HOME=/data/data/com.android.term

./mono test.exe

I have updated the APK on the Market with my latest changes. I also have the APK available for direct download.

Next task: create a JNI lib that can access Mono... should be fairly easy. (Calling into the lib will automatically set the HOME directory for you as well)

4 comments:

di said...

Good god, i can't believe you've actually gone and ported Mono to android...!

Well. Next stop system.net and the gui goodness, right? Gui would be very very grand indeed.

Alex Kovar said...

Hey,

Just wanted to say good job! Originally I dismissed this app as useless when I saw it in the app store but after looking at your page and blog I'm rather impressed with the work you've put into this. Also those benchmarks you provided gave some very interesting results. I'd like to see more on that. Keep up the good work!

Koush said...

No worries! I'd be the first to admit that in its current state it is useless. :) However, Mono has great potential to improve the platform once the kinks are worked out and integration with Android is implemented!

Anonymous said...

hi..

In my android application ,I used JNI for building .so files. now its works. but when i link it with the libchm.so file its cant load library. and my application failed. it cant find .so files in usr/lib directory. i dont know how to get path of the .so file..

please help me.
thnx.