Building Mono using the Android NDK

I finally got around to looking at the Android NDK yesterday. It is basically a subset of the Android Source build environment, but it has all the bits necessary to compile Mono. It only took a bit of finagling with the Android.mk to make everything work right. Building for Android is pretty easy now; the longest part is actually downloading and building the mcs assemblies. There’s a script to handle that though.

The androidmono repository has updated instructions.

10 comments:

Firebird said...

Hi! First of all I know my English is not ver good because English is not my maternal language. The second is thanks! I think that this project is ver usefull and I would like to start developing in c# for my mobile. And last, and the most important, I need to know what are the requeriments for a debian machine or other linux based distribution because I'm not able to compile your project. I could build part of it but I didn't get the full project. I've installed git-core subversion autoconf libtool automake libtool bison gettext but it isn't working... Please tell me! Thanks again for your work!

GKATS said...

I appear to be stuck at the same place as Firebird. It looks like I've installed the same applications but I can't get it to complete. When I run:
./ndk-setup.sh ~/src/android-ndk
I keep getting this:
/home/greg/src/android-ndk does not contain an apps directory.

Firebird said...

I worked out I needed g++ to compile mono. Once I installed g++ and some dependencies I got mono compiled. Another thing that caused trouble was that I didn't installed Android NDK (I thought they were standalone executables, but they weren't), so install it if you haven't done it. I remeber that there was a problem with the installation script of the ndk. I solved this problem by changing the sh shell to the batch shell, and that worked for me. Also if you want you can download the apk from my webblog (http://hackersmotion.no-ip.org/) in the Android section. Hope was usseful for you GKATS!

Dr.Luiji said...

Thanks, I'll try it as soon as possible.
Cheers

Dr.Luiji

Unknown said...

Any chance of making a VMWare appliance ? (ie. Image) pre configured with ubuntu or opensuse and mono 2.6.x/android/monodevelop ready to go ???

PLEASE ???

Firebird said...

I think it's a good idea. It seems that is not difficult to do it. I also think that is not difficult to do a live cd with ubuntu. I would like to see that in action, and ='m also a volunteer to help developing that :). If anyone is interested please contac me and I will help! My email is hackersmotion@gmail.com

Koush said...

Are you guys working on Windows that you want a VMWare appliance? I can take a look at making a windows build script tonight. The idea was that this stuff should work on Windows, Mac, and Linux; just like Mono, MonoDevelop, and Android SDK do. Though I've only been testing it on Mac thus far...

GKATS: It sounds like you need to pull the latest version of androidmono. The version you have was when it was built using NDK 1.5. The latest version uses NDK 1.6.

Koush

Firebird said...

Not using Windows, using Kubuntu. I sugested to create a live CD. Is not difficult, but, when are we going to see the debugger working on linux? I think I can do it without añy problem. I would try when released, and I'll show you the results. Really like this project, hope it will continue for a long!

Unknown said...

Yes.. Windows user with VMWare OpenSuSe virtual machines..

A Windows set of script would be cool also..

Miguel said...

I am trying to get it build under Cygwin (Windows). Cygwin provided all the tools needed.
I git cloned the androidmono. Installed the ndk 1.6. Now the ./get-mono step fails to build as this:
libtool: compile: gcc -mno-cygwin -g -DHAVE_CONFIG_H -I. -I.. -I. -Wall -D_FORTIFY_SOURCE=2 -g -O2 -g -O0 -D_GNU_SOURCE -MT libeglib_la-gfile-win32.lo -MD -M
P -MF .deps/libeglib_la-gfile-win32.Tpo -c gfile-win32.c -DDLL_EXPORT -DPIC -o .libs/libeglib_la-gfile-win32.o
gfile-win32.c:42:1: warning: "S_ISREG" redefined
In file included from gfile-win32.c:34:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.h:72:1: warning: this is the location of the previous definition
gfile-win32.c:43:1: warning: "S_ISDIR" redefined
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.h:68:1: warning: this is the location of the previous definition
gfile-win32.c: In function `g_file_test':
gfile-win32.c:73: error: storage size of 'stat' isn't known
gfile-win32.c:73: warning: unused variable `stat'
make[4]: *** [libeglib_la-gfile-win32.lo] Error 1
make[4]: Leaving directory `/cygdrive/c/tools/androidmono/src/androidmono/hostbuild/mono/eglib/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/cygdrive/c/tools/androidmono/src/androidmono/hostbuild/mono/eglib'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/cygdrive/c/tools/androidmono/src/androidmono/hostbuild/mono/eglib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/cygdrive/c/tools/androidmono/src/androidmono/hostbuild/mono'
make: *** [all] Error 2
/cygdrive/c/tools/androidmono/src/androidmono/jni /cygdrive/c/tools/androidmono/src/androidmono
=====Done! Don't forget Rebuild the ARM build using the Android NDK now!=====

Will keep trying but if you have any hints I´ll appreciate them for sure.

Thanks,
Miguel Miranda de Mattos
http://mmmattos.net