I have included a SpriteFont asset and an mp3 asset in my MonoGame cross platform project, the strange thing is that the the game compiles and runs fine on the iOS simulator but whenever I try to build the game on Android I get warnings like this for the files in the bin directory and in the content directory
/Users/edward/Library/Mobile Documents/com~apple~CloudDocs/apps/Xamarin/Android/Radiant/Android/Content/lights.mp3:
Warning XA0101: #(Content) build action is not supported (XA0101) (Radiant.Droid)
And when I try and run the game, I get a
Could not load score asset as a non content file
I have tried many things such as changing the build actions of various files but nothing has worked.
This could be an issue of upper case and lower case file names. I've run into this issue before.
If it's not that, you can extract the Android *.apk file like a *.zip file to see what files are actually in there. This can seriously help on figuring out why files aren't being loaded with android.
To Extract
Create a copy of your *.apk file, so that you're not modifying the original.
Change the file extension too *.zip.
Now right click and extract like any other *.zip file.
You can then go in and explore the folder hierarchy to see what files are being included.
Check your Asset folder to see if the file you're looking for is there or not.
Hope this helps.
Are you using the monogame content builder or are you trying to load them in directly as .mp3 .png or whatever?
If you aren't using the content builder everything has to be .xnb on android.
Related
I have a question on how iOS create its folder, I have a function wherein it will generate a Pdf file and will be upload to list of attachment. In the screenshot the First Run section, this is the time the file is created F4CB04F6... is the folder where it is located.
However, when I close my application and run it again, and try to download the file, the detected path changed to FE438CE9...
Does it mean the application root is always creating a new folder?
This problem will just appear in the simulator. The path will change when you build or run the project every time. Accoridng to this case, the cause is the XCode will change the application's UUID every time.
But if you run it on the physical device, the path will be the same all the time. And you can use the relative path such as Path.Combine() to store or get the files.
I added some audio files into wwwroot/audio, used them dynamically in different views, then I wanted to make some changes. After removing the first file (UserAudio001.wav) and renaming another file to UserAudio001.wav, after debugging in application there is still the older version of the audio. I removed all of the files and debugged the app, the UserAudio001.wav was still playing.
It says that the source of the file is audio/UserAudio001.wav, it is possible to play sound from the url localhost:44329/audio/UserAudio001.wav, but from the Solution Explorer the audio folder is empty. The localhost:44329/audio url also says that there is nothing in audio folder. Cleaning the solution didn't work. Where can I find these older static files? I can't replace them with the new ones.
I am trying to program an automatic Resource Loader for my project and so it is going well. But I am stuck on the loading of the sprites. I used this for checking the file exists
if (File.Exists(contentManager.RootDirectory + "/Sprites/" + spriteName + ".png"))
However it never finds the file, even though the file exists in the Content of the project. I have checked the folders and found that the .pngs are replaced by .xnb files. So I tried changing the file extension and then was given an error in the Sprite Load function
return contentManager.Load<Texture2D>(assetName);
It only happens if I change it from being a typical image file (png, bmp, etc). Can someone explain why this is the problem and how I can get around this? I have had no experience in the xna file extensions and can not find the answers I need. What I want is to load a new image into the project providing it exists in the Content Directory after compile
While on the topic, will the Sounds and Music be effected by the Compiler?
When you use a content project, the resources are imported, processed and write to disk again as xnb files.
If you want to dynamically load resources you have to compile files on the fly through the content builder or avoid using the content project.
Microsoft provides examples like this to load content dynamically: http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2
if you want to distribute the application, the runtime xna is not enoigh, you need full xna framework and visual studio installed to work.
if you want the original files in the content project, you have to change their "copy to output folder" property to "copy always", and realize that the compiled results will be at "project folder\bin\debug\content"
I have written some code for saving an image to a folder in asp.net. My problem is that the image in the folder is white and is not the same as images added manually to the folder.
I used a simple asp.net fileupload control to save the file to the correct path. But the images dont display on the page and this is how the file icons look in visual studio.
Anybody know why this is?
Try Right-clicking the images and select "include in project"
edit
If you want to do that programmatically you need to modify the project file programmatically; that's all there is to it. It's an XML file with nothing special about it. Note, however, that you have this under source control and you'll probably need to do more than just modifying the project file (ie adding the file to source control too)
Yes, it is. Because it is not included as part of the project files.
Try this:
There isn't anything else that is wrong. Only the files are not tracked by VS, so they won't be published. Your files are still completely accessible from your code.
In my opinion, files like say images added to your web app shouldn't be part of the project.
You need to include them in the project by right clicking them and click Include In Project.
Furthermore, if you want these files to included in the build you need to go to Properties of each file and set Build Action as Content.
I created a XNA Game Library Project that loads several sound and image files. But for the project to run, I need to convert these to XNB files. I am wondering, how do you go about doing that? Thanks!
The XNA Content Pipeline takes care of much of that for you. If you are using the XNA Game Studio, importing many types of content files will automatically hook up the right pipeline (which you can then edit).