Hello,
I just installed Monogame NuGet package into an Android project in Xamarin Studio 5.5.4 on a Mac.
I created an android application, added the nuget package and tried to build&run. No changes whatsoever.
Trying to run this results in an exception being thrown in Game1 ctor - any ideas what is happening and how can this be fixed? The behaviour is the same for version 3.0.1 and 3.2.2 by the way…
Many thanks!
See the stack trace below:
Java.Lang.NullPointerException:
at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>
at Android.Runtime.JNIEnv.NewObject (intptr,intptr,Android.Runtime.JValue[]) [0x00030] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:608
at Android.Runtime.JNIEnv.CreateInstance (intptr,string,Android.Runtime.JValue[]) [0x00034] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:333
at Android.Runtime.JNIEnv.CreateInstance (System.Type,string,Android.Runtime.JValue[]) [0x00007] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:351
at Android.Runtime.JNIEnv.StartCreateInstance (System.Type,string,Android.Runtime.JValue[]) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:296
at Android.Views.SurfaceView…ctor (Android.Content.Context) [0x0003c] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.Views.SurfaceView.cs:37
at OpenTK.GameViewBase…ctor (Android.Content.Context) [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/GameViewBase.cs:40
at OpenTK.Platform.Android.AndroidGameView…ctor (Android.Content.Context) [0x0004b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:65
at at Microsoft.Xna.Framework.AndroidGameWindow…ctor (Android.Content.Context,Microsoft.Xna.Framework.Game) <IL 0x00002, 0x0004f>
at at Microsoft.Xna.Framework.AndroidGamePlatform…ctor (Microsoft.Xna.Framework.Game) <IL 0x00036, 0x001d7>
at at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game) <IL 0x00001, 0x0005f>
at at Microsoft.Xna.Framework.Game…ctor () <IL 0x00208, 0x00f77> at AndroidTest.Game1…ctor () [0x00000] in /Users/kurt/Projects/XamarinTest1/AndroidTest/Game1.cs:14
at AndroidTest.Activity1.OnCreate (Android.OS.Bundle) [0x00008] in /Users/kurt/Projects/XamarinTest1/AndroidTest/GameActivity.cs:20
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.App.Activity.cs:1559
at at (wrapper dynamic-method) object.96dbb17a-38b9-4844-900b-fad39393b26d (intptr,intptr,intptr) <IL 0x00017, 0x00043>
at — End of managed exception stack trace —
at java.lang.NullPointerException
at at android.view.ViewConfiguration.get(ViewConfiguration.java:228)
at at android.view.View.(View.java:1878)
at at android.view.SurfaceView.(SurfaceView.java:169)
at at opentk.GameViewBase.(GameViewBase.java:19)
at at opentk.platform.android.AndroidGameView.(AndroidGameView.java:23)
at at microsoft.xna.framework.AndroidGameWindow.(AndroidGameWindow.java:28)
at at androidtest.Activity1.n_onCreate(Native Method)
at at androidtest.Activity1.onCreate(Activity1.java:28)
at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at at android.os.Handler.dispatchMessage(Handler.java:99)
at at android.os.Looper.loop(Looper.java:123)
at at android.app.ActivityThread.main(ActivityThread.java:3683)
at at java.lang.reflect.Method.invokeNative(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:507)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at at dalvik.system.NativeStart.main(Native Method)
Thanks for your quick reply. Your suggestion got me further. Unfortunately this time I get a different exception message:
Failed to find a valid GraphicsMode configuration - see the call stack below. This happens when I try to deploy it to the predefined AVD MonoForAndroid_API_10 - when I try to create my own device and deploy on that one I always get an error message saying: “Deployment failed. Assembly synchronization error”. Tried with HW GPU on/off, various screen resolutions, API 10/12, no difference
[MonoGame] Creating Color:Default Depth:24 Stencil:0
[MonoGame] Failed to create desired format, falling back to defaults
[Mono] DllImport attempting to load: ‘/system/lib/liblog.so’.
[Mono] DllImport loaded library ‘/system/lib/liblog.so’.
[Mono] DllImport searching in: ‘/system/lib/liblog.so’ (’/system/lib/liblog.so’).
[Mono] Searching for ‘__android_log_print’.
[Mono] Probing ‘__android_log_print’.
[Mono] Found as '_android_log_print’.
[MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] OpenTK.Platform.Android.EglException: Failed to find a valid GraphicsMode configuration
[MonoDroid] at OpenTK.Platform.Android.AndroidGraphicsMode.ChooseConfig (Javax.Microedition.Khronos.Egl.EGLDisplay) [0x0036e] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGraphicsMode.cs:187
[MonoDroid] at OpenTK.Platform.Android.AndroidGraphicsMode.Initialize (Javax.Microedition.Khronos.Egl.EGLDisplay,int) [0x0000a] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGraphicsMode.cs:226
[MonoDroid] at OpenTK.Platform.Android.AndroidGraphicsContext.Init (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,int,OpenTK.Graphics.GraphicsContextFlags) [0x000a9] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGraphicsContext.cs:114
[MonoDroid] at OpenTK.Platform.Android.AndroidGraphicsContext…ctor (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,OpenTK.Graphics.GLContextVersion,OpenTK.Graphics.GraphicsContextFlags) [0x00015] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGraphicsContext.cs:88
[MonoDroid] at OpenTK.Platform.Android.AndroidGraphicsContext.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,OpenTK.Graphics.GLContextVersion,OpenTK.Graphics.GraphicsContextFlags) [0x00007] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGraphicsContext.cs:50
[MonoDroid] at OpenTK.Platform.Android.AndroidGameView.CreateContext () [0x0001b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:388
[MonoDroid] at OpenTK.Platform.Android.AndroidGameView.MakeCurrent () [0x00013] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:200
[MonoDroid] at Microsoft.Xna.Framework.AndroidGameWindow.OnLoad (System.EventArgs) <IL 0x00008, 0x0006f>
[MonoDroid] at OpenTK.Platform.Android.AndroidGameView.LoadInternal (System.EventArgs) [0x00003] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:282
[MonoDroid] at OpenTK.Platform.Android.AndroidGameView.SurfaceCreated (Android.Views.ISurfaceHolder) [0x00052] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:113
[MonoDroid] at Microsoft.Xna.Framework.AndroidGameWindow.Android.Views.ISurfaceHolderCallback.SurfaceCreated (Android.Views.ISurfaceHolder) <IL 0x00002, 0x0004b>
[MonoDroid] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.Views.ISurfaceHolder.cs:180
[MonoDroid] at (wrapper dynamic-method) object.b76f442c-6c8e-49d6-9fd5-a96a5d0ac75e (intptr,intptr,intptr) <IL 0x00017, 0x00043>