Exception on launch on Android

I’m getting an exception with the following call stack when I try to run a android build of my project in Xamarin. It appears just after the Monogame game logo. This is with the latest release build of Monogame. Anyone seen this before?

System.Diagnostics.Debugger.Mono_UnhandledException_internal () in 
System.Diagnostics.Debugger.Mono_UnhandledException (ex=) in 
object.a7089211-7496-43ea-bee0-54f978428925 (Parameters=) in 
Microsoft.Xna.Framework.MonoGameAndroidGameView.OnLoad (Parameters=) in 
OpenTK.Platform.Android.AndroidGameView.LoadInternal (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:290
OpenTK.Platform.Android.AndroidGameView.SurfaceCreated (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:118
Microsoft.Xna.Framework.MonoGameAndroidGameView.Android.Views.ISurfaceHolderCallback.SurfaceCreated (Parameters=) in 
Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.ISurfaceHolder.cs:180
object.a7089211-7496-43ea-bee0-54f978428925 (Parameters=) in

You have an unhandled exception in your initializer. Debug it and catch it :slight_smile:

Hmm. Any advice for tracking that down? I’ve commented out everything in my game class that could be causing it so it’s pretty much the same as the default one from the project but the exception still appears

I guess you are using Xamarin Studio. Create a new breakpoint from the debug dropdown and make it break on all exceptions like this:

Select ‘System.Exception’ in the new dialog and ensure the ‘Include
Subclasses’ button is checked.

Thanks! That gives me a bit more info but I’m still a bit lost. None of the callstack seems to be in my code. It looks like an OpenTK problem

OpenTK.Platform.Android.AndroidGraphicsMode.ChooseConfig (display=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGraphicsMode.cs:192
OpenTK.Platform.Android.AndroidGraphicsMode.Initialize (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGraphicsMode.cs:233
OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:189
Microsoft.Xna.Framework.MonoGameAndroidGameView.CreateFrameBuffer (Parameters=) in 
OpenTK.Platform.Android.AndroidGameView.CreateSurface (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:365
OpenTK.Platform.Android.AndroidGameView.SurfaceCreated (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:112
Microsoft.Xna.Framework.MonoGameAndroidGameView.Android.Views.ISurfaceHolderCallback.SurfaceCreated (Parameters=) in 
Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (Parameters=) in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.ISurfaceHolder.cs:180
object.3cb1b708-dfdc-4bfb-a15c-87e0ccefa938 (Parameters=) in

Are you able to tell us what type of exception it is, and what the exception details are? If you build from MonoGame source, can you step through the CreateFrameBuffer method in MonoGameAndroidGameView and find some more details?

Ah that helped. Turned out it was a problem with the emulator. Turning on “use host GPU” fixed it