Content loading, .xnb, "non-content file!"

Hi, I’m developing couple of games and for one particular I get the following error when trying to load .xnb files with textures:

Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\\Loading asset as a non-content file!

The weird thing is as follows - the file has properties set to AndroidAsset / CopyAlways and is packed into the .apk file. If I replace it with original .png file and put it in the same place, it will load having very bright colors. To load the resource I’m using the following code:

content.Load<Texture2D>("Graphics\\Loading");

What really bothers me is that I’m using exactly the same setup on different projects (i.e. my tutorial on github) and it works perfectly. However, with this project I have before-mentioned issue. Any ideas what could be causing this? [I tried both referencing the MonoGame binaries NuGet package as well as the latest source code that I built locally]

How did you create the XNB file?

I ran into a the same error when I just copied and included the XNB files from a Windows project. The content processor I used originally in my VS2010 project was the “Texture - XNA Framework”. I generated XNA files which worked for iOS in my case by using a “MonoGame Content” project and then the “MonoGame Texture” content processor for the images with platform type iOS (in your case you would chose Android).
Or you could try the new Pipeline Tool for Mac OS and Linux http://www.monogame.net/2015/01/09/monogame-pipeline-tool-available-for-macos-and-linux/.

Previously I used the old XNA build project, but for all my current projects (including the tutorial on github which works fine, and the project that is broken) I’m using the Pipeline tool which I created from sources.

Android uses a case-sensitive file system. Make sure the filename is exactly correct, including upper- and lower-case.

1 Like

I double checked that, it is exactly the same name. As I said - if I replace .xnb with original .png file and place it in the same location, then the texture is loaded (however slightly brighter than it should be). Also, I’m using the same .xnb files in Windows Phone project and they are working flawlessly (so it’s not a case of 0 byte .xnb file or corrupted data in these files).

They may be compressed using DXT, and most Android devices do not support DXT compression.

They are not compressed, just double checked it in the Pipeline tool. However, in that particular project I was using texture atlases - so on a single texture of size 2048x2048 I actually had multiple different objects, which I then cut out from the atlas using source rectangle in the Draw call. When I replaced the atlases with a lot of small textures (one per graphic game object, sizes 50x800 or similar), and then load them from .xnb files everything works fine on Android.

My guess is that the initial size of the texture was too big for my testing device (Sony Xperia J, should handle 2048x2048 though…)

OR

the Pipeline tool messed up the textures with such big sizes - as I mentioned, I used the original XNA content pipeline project before and it compiled my textures correctly, even having these big atlases - it worked on my testing device without any problems.

Summary: I managed to fix it by splitting textures into smaller sizes and it works for me now, dunno what exactly caused the problem unfortunately. The only change I did in the setup of my project was to remove the XNA Content Pipeline project and use the Pipeline tool to create .xnb files for my project.