Monogame content load file no exception found

The following post is similar to my problem, but in the end it does not look exactly the same as all the details, so I call this to prevent claims that it is the same.

I follow this monogame tutorial (currently in step 2) in Xamarin Studio:

When I run the resulting monogame application at the end of step 2, I get the following exception (inserted at the end) when I click on a line of code that tries to load the contents of the player. I correctly configured the contents file of the AFAIK file, it was copied to the output folder, but I assume that it somehow could not be installed correctly on the Andriod virtual machine (AVM), and I could not figure out how to examine the expanded content. I stopped Android Monitor to investigate AVM and try to find out where this happens, but it didn’t occur to me that this is impossible ... The exception thrown in the file seems clear that what works on AVM is not a search for the content file. .. but I can’t figure out how to fix it.

Any help would be appreciated, thanks!

The sources and the project I came across are here

The exception that I see is the following: [MonoDroid] UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Failed to load the Graphics \ player resource as a file containing no content! ---> Microsoft.Xna.Framework.Content.ContentLoadException: error opening thread. ---> Java.IO.FileNotFoundException: An exception of type "Java.IO.FileNotFoundException" was thrown. [MonoDroid] on Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue [] parms) [0x00000] at: 0 [MonoDroid] on Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] at: 0 [MonoDroid] at Microsoft.Xna.Framework.TitleContainer.OpenStream (name System.String) [0x00000] at: 0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (system .String assetName) [0x00000] in: 0 [MonoDroid] --- The end of the managed exception stack trace --- [MonoDroid] java.io.FileNotFoundException: Content / Graphics / player.xnb [MonoDroid] on android.content.res. AssetManager.openAsset (Native Method) [MonoDroid] on android.content.res.AssetManager.open (AssetManager.javahaps15) [MonoDroid] on android.content.res.AssetManager.open (AssetManager.java:289) [MonoDroid] on mono.java.lang.RunnableImplementor.n_run (Native Method) [MonoDroid] on mono.java.lang.RunnableImplementor.run (RunnableImplementor.java:29) [MonoDroid] on android.os.Handler.handleCallba ck (Handler.java:605) [MonoDroid] on android.os.Handler.dispatchMessage (Handler.java:92) [MonoDroid] on android. os.Looper.loop (Looper.java:137) [MonoDroid] on android. app.ActivityThread.main (ActivityThread.java:4424) [MonoDroid] in java.lang.reflect.Method.invokeNative (native method) [MonoDroid] in java.lang.reflect.Method.invoke (Method.java∗11) [ MonoDroid] on com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:784) [MonoDroid] on com.android.internal.os.ZygoteInit.main (ZygoteInit.java UP51) [MonoDroid] on dalvik .system.NativeStart.main (Native Method) [MonoDroid] [MonoDroid] --- End of internal stack trace --- [MonoDroid] in Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String propertyName) [0x00000] at: 0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset [Texture2D] (System.String propertyName, System.Action1 recordDisposableObject) [0x00000] at: 0 [MonoDroid] --- End of internal check for exception stack - - [MonoDroid] in Microsoft.Xna.Framework.Content.ContentManager.ReadAsset ( channel, System.Action1) <0x0042c> [MonoDroid] in Microsoft.Xna.Framework.Content.ContentManager.Load (string) <0x000c3> [MonoDroid] in SampleShooter.Game1.LoadContent () <0x0018b> [MonoDroid] in Microsoft. Xna.Framework.Game.Initialize () <0x0023f> [MonoDroid] in SampleShooter.Game1.Initialize () <0x00037> [MonoDroid] in Microsoft.Xna.Framework.Game.DoInitialize () <0x00037> [MonoDroid] in Microsoft. Xna.Framework.AndroidGamePlatform.BeforeUpdate (Microsoft.Xna.Framework.GameTime) <0x0002b> [MonoDroid] on Microsoft.Xna. Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime) <0x0002f> [MonoDroid] in Microsoft.Xna.Framework.Game.Tick () <0x00493> [MonoDroid] in Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame (Open .FrameEventArgs) <0x000a7> [MonoDroid] in OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal (OpenTK.FrameEventArgs) <0x00033> [MonoDroid] in OpenTK.Platf orm.Android.AndroidGameView.Runtement.Runtame > [MonoDroid] in OpenTK.Platform.Android.AndroidGameView / c__AnonStorey0. <> m__2 (object) <0x00027> [MonoDroid] on Android.App.SyncContext / c__AnonStorey2F. <> m__1A () <0x00023> [MonoDroid] in Java.Lang.Thread / RunnableImplementor.Run () <0x0003f> [MonoDroid] in Java.Lang.IRunnableInvoker.n_Run (intptr, intptr) <0x00037> [MonoDroid] at ( wrapper dynamic-method) object.e85befee-f4e0-4f15-9232-77621081c7b5 (intptr, intptr) <0x0003b> [mono] [mono] Unhandled Exception: [mono] Microsoft.Xna. Framework.Content.ContentLoadException: Failed to load Graphics \ player resource as file without content! ---> Microsoft.Xna.Framework.Content.ContentLoadException: error opening thread. ---> Java.IO.FileNotFoundException: An exception of type "Java.IO.FileNotFoundException" was thrown. [mono] on Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue [] parms) [0x00000] at: 0 [mono] on Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] at: 0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (name System.String) [0x00000] at: 0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System .String propertyName) [0x00000] in: 0 [mono] --- End managed trace of exception stack --- [mono] java.io.FileNotFoundException: Content / Graphics / player.xnb [mono] at android.content.res. AssetManager.openAsset (native method) [mono] on android.content.res. AssetManager.open (AssetManager.ja [mono] [ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load the Graphics \ player resource as a file without content! ---> Microsoft.Xna.Framework. Content.ContentLoadException: Error opening thread. ---> Java.IO.FileNotFoundException: an exception of the type "Java.IO.FileNotFoundException" [Mono] in Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android. Runtime.JValue [] parms) [0x00000] at: 0 [mono] on Android.Content.Res.AssetManager.Open (System.String file_name) [0x00000] at: 0 [mono] on Microsoft.Xn a.Framework.TitleContainer .OpenStream (name System.String) [0x00000] at: 0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String propertyName) [0x00000] at: 0 [mono] - - End of stack trace for corrected exceptions --- [mono] java.io.FileNotFoundException: Content / Graphics / player.xnb [mono] at android.content.res.AssetManager.openAsset (Native Method) [mono] in android. content.res.AssetManager.open (like

+4
source share
2 answers

So, I finally realized that I need to mark the XNB file as AndroidAsset for the assembly action, and not Content as an example. Since the example below is aimed at developing Windows Mobile, it makes sense since the file is usually marked as content for a Windows application, whereas for Android these files must be marked as AndriodAsset so that XNA can access the raw content data, regardless whether the file is in the content or resource folder. The root folder of the content manager is “Content” by default, so you need to add the file there and mark it as a resource, not content ...

+7
source

Content for the monogame project for Android should be added to the project in the Assets / Content folder as embedded .xnb files, and not just copied to the output directory

+2
source

Source: https://habr.com/ru/post/1482772/


All Articles