Crash when using MonoGame.Framework.dll built from source

Hello,
I’m trying to get a version of MonoGame.Framework.dll for Android to build on my computer.
I’ve made not changes to this source code–just trying to use it in place of the pre-built MonoGame.

When I copy the new DLL built from source (3.2), over the ‘installed’ version of MonoGame 3.2, any test game that I try to run on an Android device crashes.

It should be as simple as:

  1. Compile MonoGame.Framework for Android.
  2. Run test Android game on device, with this new, from-source DLL linked as a resource (not the original version).
    Instead it crashes, as listed below.

Details:
My build environment is Windows 8.1, Visual Studio 2013. I have an Ouya and an Amazon Fire TV that I’ve tried this on.
I’m new to building MonoGame from source, but I’ve programmed in XNA for years. There’s definitely something though that I could have messed up here.

Here’s what I’ve run into.
I’ve installed the pre-compiled (non-source) 3.2 of MonoGame.
I have Xamarin 3.7.248 installed (the basic thing that the XamarinInstaller.exe installs automatically–nothing special but it’s up to date).
In VS2013 if I make a new MonoGame Android project from the template and run it on a device (like the Ouya), the cornflower blue screen shows and the Hello World style game runs fine.

I’ve also downloaded (zip from GitHub) the 3.2 source code for MonoGame.
If I compile the source for MonoGame.Framework.Android.sln in VS 2013, then copy the resulting DLL over my in-use copy of MonoGame.Framework.DLL, and then try to run a test Android Hello World game, it crashes. (Cleaned and rebuilt of course.)

Crash is:

System.Diagnostics.Debug.Assert(Boolean condition, System.String message)
    Microsoft.Xna.Framework.AndroidGamePlatform..ctor(Microsoft.Xna.Framework.Game game)
    Microsoft.Xna.Framework.GamePlatform.Create(Microsoft.Xna.Framework.Game game)
    Microsoft.Xna.Framework.Game..ctor()
    testLinkAndroid6.Game1..ctor()
    testLinkAndroid6.Activity1.OnCreate(Android.OS.Bundle bundle)
        11-18 04:50:38.385 I/mono-stdout( 5683):    at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState)
        11-18 04:50:38.385 I/mono-stdout( 5683):    at System.Object.90d77806-ac49-4340-a3e8-cce31574b454(IntPtr , IntPtr , IntPtr )
        Unhandled Exception:  Java.Lang.NullPointerException: 

This is it dying when trying to ‘new’ the Game, from the Activity. I’ve tried to fix it, with the following before the Game new:

Microsoft.Xna.Framework.Game.Activity = this;

Which allows the Game to complete the new, but then ends up with a crash in the following line in my Activity.

SetContentView((View)g.Services.GetService(typeof(View)));

It seems the ‘g’ (the Game) is allocated, but when I try to convert it to a View, that yields null. Again, this is simply the template Game.cs and Activity1.cs generated from a MonoGame Android template from v3.2.

Is there any trick to building the source on my computer?
Can I simply build the Android solution for the MonoGame.Framework or do I need to … build more first?
Should I build everything in MonoGame and have the entire folder overwritten with everything built from source?

Definitely struggling here, help would be great!

(PS. The reason I’m trying this, is to try to get the controller running for Fire TV as it’s not receiving KeyUp, KeyDown correctly. So my course was to get the MonoGame.Framework.dll for Android building on my controller and then try a possible fix. But I’m hung up on the very first step!)
Thank you!

  • Nathan

Hi Nathan - I’ve recently run into the exact same problem (I downloaded the latest source from GitHub).

Did you find a solution?

Many thanks, Ian.

Hi Ian, unfortunately I never solved this. I worked on it for a while longer, but couldn’t get around it. After a time, the publisher backed out anyways, so I didn’t need to solve it anymore. Sorry.