Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

monogame content load file not found exception

The following post looks similar to my issue, but ultimately it doesn't look exactly the same down to all the details, so I am calling that out to prevent claims that its the same.

I am following this monogame tutorial (currently on step 2) in Xamarin Studio:

When I run the resulting monogame app at the end of step 2 I get the following exception (pasted at the end) when I hit the line of code that attempts to load the player content. I have the player content file setup correctly AFAIK, its copied to the output folder, but I am assuming that its somehow not deployed correctly to the Andriod Virtual Machine (AVM), which I have not been able to figure out how to examine the deployed contents. I pulled up Android Monitor to explore the AVM and try to figure out where things are, but I haven't had any luck figuring that out... The file not found exception seems to be clear that what's running on the AVM isn't finding the content file... but I can't figure out how to correct that.

Any help would be appreciated, thanks!

The sources and project that I am having this issue with are here

The exception I am seeing is the following: [MonoDroid] UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [MonoDroid] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [MonoDroid] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] --- End of managed exception stack trace --- [MonoDroid] java.io.FileNotFoundException: Content/Graphics/player.xnb [MonoDroid] at android.content.res.AssetManager.openAsset(Native Method) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:315) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:289) [MonoDroid] at mono.java.lang.RunnableImplementor.n_run(Native Method) [MonoDroid] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29) [MonoDroid] at android.os.Handler.handleCallback(Handler.java:605) [MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:92) [MonoDroid] at android.os.Looper.loop(Looper.java:137) [MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:4424) [MonoDroid] at java.lang.reflect.Method.invokeNative(Native Method) [MonoDroid] at java.lang.reflect.Method.invoke(Method.java:511) [MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) [MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) [MonoDroid] at dalvik.system.NativeStart.main(Native Method) [MonoDroid] [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[Texture2D] (System.String assetName, System.Action1 recordDisposableObject) [0x00000] in :0 [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset (string,System.Action1) <0x0042c> [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.Load (string) <0x000c3> [MonoDroid] at SampleShooter.Game1.LoadContent () <0x0018b> [MonoDroid] at Microsoft.Xna.Framework.Game.Initialize () <0x0023f> [MonoDroid] at SampleShooter.Game1.Initialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.Game.DoInitialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.AndroidGamePlatform.BeforeUpdate (Microsoft.Xna.Framework.GameTime) <0x0002b> [MonoDroid] at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime) <0x0002f> [MonoDroid] at Microsoft.Xna.Framework.Game.Tick () <0x00493> [MonoDroid] at Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame (OpenTK.FrameEventArgs) <0x000a7> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal (OpenTK.FrameEventArgs) <0x00033> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) <0x001c3> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView/c__AnonStorey0.<>m__2 (object) <0x00027> [MonoDroid] at Android.App.SyncContext/c__AnonStorey2F.<>m__1A () <0x00023> [MonoDroid] at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f> [MonoDroid] at 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: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(AssetManager.ja [mono] [ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(As

like image 312
BotHead Avatar asked May 26 '13 01:05

BotHead


1 Answers

So I finally figured out that I needed to mark the XNB file as an AndroidAsset for the build action, and not Content as the example stated. Since the example I am following is aimed at Windows Mobile development this makes sense since the file would normally be marked as content for a Windows application, whereas for Android these files need to be marked as AndriodAsset in order for XNA to be able to access the raw content data, regardless of if the file is in a content or asset folder. The content manager's root folder by default is "Content", so you need to add the file there and mark it as an asset, not content...

like image 120
BotHead Avatar answered Sep 22 '22 10:09

BotHead