F# and Monogame Part 2 – Android

In my last post I showed how to get a Monogame Game class running on MacOS. This time it’s Android’s turn.

I’m going to assume you already have Xamarin Studio, the F# Android templates and Monogame installed.

Getting started

Create a new “Android Application” from under the F# Language tree node.

Add references to MonoGame.Framework.dll and Lindgren.Network.dll for Android. You’ll also need a reference to OpenTK (not 1.0).

Using the same Game definition from the MacOS tutorial –

type Game() as game =
    inherit Microsoft.Xna.Framework.Game() 
    let manager = new Microsoft.Xna.Framework.GraphicsDeviceManager(game)
    override __.Draw _ = game.GraphicsDevice.Clear Microsoft.Xna.Framework.Color.CornflowerBlue

In MainActivity.fs change the MainActivity to inherit from


And in the OnCreate member replace the content with

override this.OnCreate (bundle) = 
   base.OnCreate (bundle)

   Game.Activity <- this
   let game = new Game()

You should now see a lovely blue screen when running on an Android Device. I highly recommend owning an Android device for development as the emulators are rather slow….

Quick note:

On other platforms you usually put Content in the Content folder. On Android you’ll put content in the Assets/Content. For the content add it to the project and set it’s Build Action to AndroidAsset. I’ll be covering building assets for different platforms using the content pipeline in a future post, but in Monogame you can also load some files (such as png) without pre-processing through the content pipeline.

About thedo666

Software developer trying to learn a new language - English!
This entry was posted in Android, F#, Mono and tagged , , . Bookmark the permalink.

4 Responses to F# and Monogame Part 2 – Android

  1. Pingback: F# Weekly #31 2013 | Sergey Tihon's Blog

  2. Pingback: Xamarin Link Roundup – 6 Aug 2013 | Well Technically…

  3. Pingback: F# and Monogame Part 4 – Content Pipeline | Neil Danson's Blog

  4. Pingback: F# on Android

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s