I’m at my wits end with this one. I’m not an Android expert by a long shot but I’ll try and describe my setup.
My engine (more like a set of reusable tools) and game are in their own libraries so that I can easily build dlls for each platform and move them around using conditional references.
Setting up my game for Ouya deployment, something I haven’t done in a quite long time nor with the latest monogame version, I get a crash as soon as the game launches. It looks like the Java native call (or however it communicates with C#) to invoke the constructor fails when it calls the Game.cs constructor. It steps through my game and my engine classes that extend Game.cs, but when it gets to the base call to Game() is chokes.
I’ve seen that this could be due to having dlls built for the wrong target platform so I rebuilt my projects with no conditional reference and I still have this same issue. I’m thinking this is some weird project set up thing with Xamarin but I’m willing to take and guesses as this point.
Here is my logcat when the game crashes:
I/MonoDroid(10941): UNHANDLED EXCEPTION: Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
I/MonoDroid(10941): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x001ac>
I/MonoDroid(10941): at Android.Runtime.JNIEnv.InvokeConstructor (intptr,string,Android.Runtime.JValue[]) <0x000b3>
I/MonoDroid(10941): at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,string,Android.Runtime.JValue[]) <0x00037>
I/MonoDroid(10941): at Android.Views.SurfaceView..ctor (Android.Content.Context) <0x0018f>
I/MonoDroid(10941): at OpenTK.GameViewBase..ctor (Android.Content.Context) <0x0001b>
I/MonoDroid(10941): at OpenTK.Platform.Android.AndroidGameView..ctor (Android.Content.Context) <0x0008f>
I/MonoDroid(10941): at Microsoft.Xna.Framework.AndroidGameWindow..ctor (Android.Content.Context,Microsoft.Xna.Framework.Game) <0x0001f>
I/MonoDroid(10941): at Microsoft.Xna.Framework.AndroidGamePlatform..ctor (Microsoft.Xna.Framework.Game) <0x00153>
I/MonoDroid(10941): at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game) <0x00023>
I/MonoDroid(10941): at Microsoft.Xna.Framework.Game..ctor () <0x00933>
I/MonoDroid(10941): at Platformer.PlatformerGame..ctor () <0x00033>
I/MonoDroid(10941): at KnightAndDamsel.KDGame..ctor () <0x0001b>
I/MonoDroid(10941): at KnightAndDamsel.Ouya.Activity1.OnCreate (Android.OS.Bundle) <0x0002f>
I/MonoDroid(10941): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
I/MonoDroid(10941): at (wrapper dynamic-method) object.98b7e707-8838-482f-88e5-6d9b5c1894c8 (intptr,intptr,intptr) <0x00043>
I/MonoDroid(10941):
I/MonoDroid(10941): --- End of managed exception stack trace ---
I/MonoDroid(10941): java.lang.NullPointerException
I/MonoDroid(10941): at android.view.ViewConfiguration.get(ViewConfiguration.java:332)
I/MonoDroid(10941): at android.view.View.<init>(View.java:3236)
I/MonoDroid(10941): at android.view.SurfaceView.<init>(SurfaceView.java:176)
I/MonoDroid(10941): at opentk.GameViewBase.<init>(GameViewBase.java:19)
I/MonoDroid(10941): at opentk.platform.android.AndroidGameView.<init>(AndroidGameView.java:23)
I/MonoDroid(10941): at microsoft.xna.framework.AndroidGameWindow.<init>(AndroidGameWindow.java:29)
I/MonoDroid(10941): at knightanddamsel.ouya.Activity1.n_onCreate(Native Method)
I/MonoDroid(10941): at knightanddamsel.ouya.Activity1.onCreate(Activity1.java:28)
I/MonoDroid(10941): at android.app.Activity.performCreate(Activity.java:5063)
I/MonoDroid(10941): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
I/MonoDroid(10941): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
I/MonoDroid(10941): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
I/MonoDroid(10941): at android.app.ActivityThread.access$600(ActivityThread.java:130)
I/MonoDroid(10941): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
I/MonoDroid(10941): at android.os.Handler.dispatchMessage(Handler.java:99)
I/MonoDroid(10941): at android.os.Looper.loop(Looper.java:137)
I/MonoDroid(10941): at android.app.ActivityThread.main(ActivityThread.java:4745)
I/MonoDroid(10941): at java.lang.reflect.Method.invokeNative(Native Method)
I/MonoDroid(10941): at java.lang.reflect.Method.invoke(Method.java:511)
I/MonoDroid(10941): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
I/MonoDroid(10941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
I/MonoDroid(10941): at dalvik.system.NativeStart.main(Native Method)
E/mono (10941):
E/mono (10941): Unhandled Exception:
E/mono (10941): Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
E/mono (10941): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x001ac>
E/mono (10941): at Android.Runtime.JNIEnv.InvokeConstructor (intptr,string,Android.Runtime.JValue[]) <0x000b3>
E/mono (10941): at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,string,Android.Runtime.JValue[]) <0x00037>
E/mono (10941): at Android.Views.SurfaceView..ctor (Android.Content.Context)<0x0018f>
E/mono (10941): at OpenTK.GameViewBase..ctor (Android.Content.Context) <0x0001b>
E/mono (10941): at OpenTK.Platform.Android.AndroidGameView..ctor (Android.Content.Context) <0x0008f>
E/mono (10941): at Microsoft.Xna.Framework.AndroidGameWindow..ctor (Android.Content.Context,Microsoft.Xna.Framework.Game) <0x0001f>
E/mono (10941): at Microsoft.Xna.Framework.AndroidGamePlatform..ctor (Microsoft.Xna.Framework.Game) <0x00153>
E/mono (10941): at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game) <0x00023>
E/mono (10941): at Microsoft.Xna.Framework.Game..ctor () <0x00933>
E/mono (10941): at Platformer.PlatformerGame..ctor
E/mono-rt (10941): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
E/mono-rt (10941): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x001ac>
E/mono-rt (10941): at Android.Runtime.JNIEnv.InvokeConstructor (intptr,string,Android.Runtime.JValue[]) <0x000b3>
E/mono-rt (10941): at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,string,Android.Runtime.JValue[]) <0x00037>
E/mono-rt (10941): at Android.Views.SurfaceView..ctor (Android.Content.Context)<0x0018f>
E/mono-rt (10941): at OpenTK.GameViewBase..ctor (Android.Content.Context) <0x0001b>
E/mono-rt (10941): at OpenTK.Platform.Android.AndroidGameView..ctor (Android.Content.Context) <0x0008f>
E/mono-rt (10941): at Microsoft.Xna.Framework.AndroidGameWindow..ctor (Android.Content.Context,Microsoft.Xna.Framework.Game) <0x0001f>
E/mono-rt (10941): at Microsoft.Xna.Framework.AndroidGamePlatform..ctor (Microsoft.Xna.Framework.Game) <0x00153>
E/mono-rt (10941): at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game) <0x00023>
E/mono-rt (10941): at Microsoft.Xna.Framework.Game..ctor () <0x00933>
E/mono-rt (10941): at Platformer.PlatforD/Zygote ( 108): Process 10941 exited cleanly (1)