Monogame Content API < 19 problem


I’m in the middle of testing my apps on different phones/tablets/emulators. Everything works just fine when I run my game on API19+. I don’t have API 18 device/emulator so I checked on API17 emulator and app crashed…
The problem is when loading Content. Everything loads ok except one Texture2D (it’s not the first Texture2D). I’ve tried to change name of it, deleting and adding again and so on. Nothing helped. When I deleted the line where I load this content (and all where I use it) everything loaded excellent.

I tried different Monogame.Framework versions, I tried even with other file with other name, but it doesn’t matter… It’s really weired…

Minimum android version - API level 15
Target Android version - API level 19 (changed it to 17, didn’t work either)
Target Framework - Android 4.4 (KitKat) (changed it to 4.2 (Jelly Bean), didn’t work).

And as I said - everything works fine with API 19+.

Exception that is being thrown:

>        System.Diagnostics.Debugger.Mono_UnhandledException (ex={Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.

>       --- End of managed exception stack trace ---
>     java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>     	at
>     	at dalvik.system.NativeStart.main(Native Method)
>     Caused by: java.lang.reflect.InvocationTargetException
>     	at java.lang.reflect.Method.invokeNative(Native Method)
>     	at java.lang.reflect.Method.invoke(
>     	at$
>     	... 2 more
>     Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Background2 asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
>       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 
>       at Android.Runtime.JNIEnv.CallIntMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00064] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:404 
>       at Java.IO.InputStream.Read (System.Byte[] buffer, Int32 byteOffset, Int32 byteCount) [0x00089] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.IO.InputStream.cs:302 
>       at Android.Runtime.InputStreamInvoker.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/InputStreamInvoker.cs:30 
>       at System.IO.Stream.InternalCopyTo (System.IO.Stream destination, Int32 bufferSize) [0x00015] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/io/stream.cs:227 
>       at System.IO.Stream.CopyTo (System.IO.Stream destination) [0x00099] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/io/stream.cs:195 
>       at (wrapper remoting-invoke-with-check) System.IO.Stream:CopyTo (System.IO.Stream)
>       at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00024] in <filename unknown>:0 
>       --- End of managed exception stack trace ---
>     	at android.content.res.AssetManager.readAsset(Native Method)
>     	at android.content.res.AssetManager.access$700(
>     	at android.content.res.AssetManager$
>     	at Method)

>       --- End of inner exception stack trace ---
>       at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00069] in <filename unknown>:0 
>       at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[Texture2D] (System.String assetName, System.Action`1 recordDisposableObject) [0x00067] in <filename unknown>:0 
>       --- End of inner exception stack trace ---
>     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
>     at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
>     at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
>     at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
>     at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:71
>     at (wrapper dynamic-method) object.9a39b24c-9c26-4a5f-95ed-fb90ae3823b3 (intptr,intptr) <IL 0x00011, 0x0001f>

>     	at Method)
>     	at
>     	at android.os.Handler.handleCallback(
>     	at android.os.Handler.dispatchMessage(
>     	at android.os.Looper.loop(
>     	at
>     	... 5 more
>     }) in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122

Plese help!

Oh, and may be important (not sure why :wink: ) - I’m loading this cointent with Task.Factory.StartNew.

Nevermind - it doesn’t matter. It doesn’t work on main thread either…

I just built a test app that ran on a friend’s Android 2.3 (API 9) device and my 4.4 (API 17) device.

The first thing to check is that you have the upper- and lower-case correct. Is the file named Background2.xnb exactly?

Yes, I checked.
I think I checked everything obvious - and it works on other Android devices don’t forget :wink:

But I don’t link xnb files to my project. That’s how my Content folder looks like:

And (one more time :wink: ) it works fine on API 19+ devices/emulators.


I updated VS Emulator for Android (update wasn’t avaliable last week) and everything started to work just fine… Maybe some bug or something…
Anyways thanks for reply :slight_smile: