Mono for Android Support

Nov 13, 2012 at 8:03 PM

I am interested in contributing a solution that compiles to a Mono for Android class library. 

Is this something that would be suitable for this project? Or is the project targeted primarily to Microsoft platforms?

Nov 15, 2012 at 4:41 AM

We would love to have 1 single code base for all platforms. We are reviewing the directory structure so we can accommodate potential new libraries or other platforms support in the future.

Clearly Microsoft/Windows is our top priority but we will welcome contributions for other platforms.

Nov 16, 2012 at 7:38 AM

I would also be interested in this too! I've been using a hand built (project linker) port of the mono version. Would be awesome to build a "real" one.

Nov 20, 2012 at 9:24 AM

Me too! Please update this thread when something is updated... 

Nov 21, 2012 at 4:08 AM
Edited Nov 21, 2012 at 3:31 PM

I've compiled the following assemblies as Mono For Android class libraries:


I am targeting Android 4.0 in the library project.

The binaries are downloadable at:

I did a couple basic tests, so If you have any Android specific issues please create an issue at:

Nov 21, 2012 at 10:08 AM

I've been using a cross compiled version of RX in my MfA project for a few weeks.

However, bear in mind that whilst you have the scaffolding (IObservable etc), what we lack is the beating heart - the platform specific schedulers.

I've been talking to Atsushi Eno who has a port here, although it has run into problems:

In Atsushi's words

"I think current MfA runtime blocks MS rx build due to some runtime crash:
This fix will be included in the next code freeze (where, current code freeze for the next is already done for the next public release and hence unfortunately this fix won't be there).
I plan to make sure things work once I get ready with working build.
So far you might be still able to use rx by my old mono-reactive that contains Rx2 API version of Android build as long as you stick to Rx1 API."

So personally, I'm just going to continue on, knowing that I can't use any of the RX scheduling (need to handle threads manually for now inc dispatching back to the UI) until Atsushi's build (or anyones!) is up and running. I need to see all of the RX unit tests passing on Android before moving over.


Dec 18, 2012 at 3:22 PM


Did you cross compile System.Reactive.PlatformServices and System.Reactive.Providers? I skipped these initially, but now have them compiling as M4A libraries... this was actually pretty straightforward requiring no code changes. 

I plan to tackle testing next, for this I'm planning to use Sebastien Pouliot's Andr Unit. I don't think it's going to be possible to simply cross compile the tests, since they rely on the visual studio testing framework, etc. and we need to test on the mono for android runtime.

I also see the bug you referenced has been marked as resolved, so hopefully there isn't anything else in the M4A runtime that is "show stopping"



Dec 18, 2012 at 3:42 PM



I also skipped the platform specific library. Glad to hear you got it over to m4a so easily. Nice one! 

Yes, I looked at trying to port the tests too. I wanted to try to implement the mstest attributes so that the tests worked unmodified. This would mean that new tests added would just run straight away without having to port them manually. I couldn't work out an easy way to do it though before losing the will to live. Any ideas? 

Dec 18, 2012 at 7:12 PM

I've started working on a Android specific scheduler and the platform specific scheduler libraries seem to work. I've added a simple Android specific scheduler to System.Reactive.Mono.Android.

Here is an example of the Android Scheduler API as a Github Gist 

Still lots of work and testing to do, but I'm not seeing any exceptions from the Rx library itself.

In terms of the attributes... I like the idea of implementing the mstest attributes, however I'm just starting to look into the unit testing side of things.

Dec 18, 2012 at 8:53 PM

Cool. For my personal needs, because I wasn't really using the threading much I just decided to concentrate on learning about all of the other parts of Android. I'm pretty new to it.

Yes, it's a bit irritating that the unit tests are in mstest and not nunit. I'd be tempted to port the entire suite of unit tests over to nunit, or at least add nunit to the project and gradually migrate them across - or divide them up amongst a group of devs to port. Perhaps someone will explain that there is a good reason that they are mstest - ah... because it was Microsoft's wasn't it.

Hence my curiosity about trying to port  the mstest attributes over. Perhaps some clever person will read this and be inspired!

Dec 18, 2012 at 10:17 PM
Edited Dec 18, 2012 at 10:19 PM

Hi Lee,

Sorry to digress, but out of curiosity why is it so important to use NUnit instead of MSTest?  What are the advantages?

Edit: Nevermind, I just noticed this comment from dmck:

"I'm planning to use Sebastien Pouliot's Andr Unit. I don't think it's going to be possible to simply cross compile the tests, since they rely on the visual studio testing framework, etc. and we need to test on the mono for android runtime."


Dec 19, 2012 at 7:31 PM

I was able to get Andr Unit and NUnitLite up and running.

I cross compiled the testing framework defined in Microsoft.Reactive.Testing as Mono.Android.Reactive.Testing by using compiler directives where there were references to the visual studio testing framework. I modified the build of NUnitLite so that the attributes aligned with the MSTest naming conventions.

To make NUnitLite work with the MSTest API I added and renamed some functions in NUnitLite. For example Assert.Equal becomes Asser.AreEqual

That was the easy part.

Tests.System.Reactive has proven to be more difficult to cross compile. 

I had to bring in System.Reactive.Experimental and System.Reactive.Runtime.Remoting. However I've still got 79 errors, with many errors of this type:

Error 472 The type 'System.Reactive.Observer' exists in both 'c:\DEVGIT\RxM4A\RxM4A\RxMonoForAndroid\System.Reactive.Linq\bin\Release\System.Reactive.Linq.dll' and 'c:\DEVGIT\RxM4A\RxM4A\RxMonoForAndroid\System.Reactive.Core\bin\Release\System.Reactive.Core.dll' C:\DEVGIT\RxM4A\Rx.NET\Tests.System.Reactive\Tests\ObservableSingleTest.cs 1806 Mono.Android.Tests.System.Reactive

When I check the Rx.NET project, I do see references to both libraries... and if I remove one or the other it causes even more errors.

Does anyone have any ideas on how to approach this problem?

Dec 20, 2012 at 1:23 PM

There was a duplicate Observer class in System.Reactive.Core and System.Reactive.Linq, they were basically the same. So I removed from Core and kept it in Linq.

I got all the unit tests cross compiling under Mono For Android with NUnitLite. I did add a "Android" compiler symbol so that stuff involving the dispatcher wasn't included.

The solution right now includes the following libraries compiling under the Mono For Android profile:

Mono.Reactive.Testing (Microsoft.Reactive.Testing)
Mono.Android.Tests.System.Reactive (Tests.System.Reactive)

And I've added:

System.Reactive.Mono.Android (this includes the Android platform specific scheduler, however it is not fully complete at this point)