I’m working in Visual Studio 2022 w/ Monogame Android templates porting an existing Monogame Win/Mac/Linux desktop title to Android. I’m learning a lot along the way, but I’ve hit a snag when it comes to basic displaying of text on real devices (P30 Lite, P30) vs. the emulator.
-Using prebuilt .xnb spritefronts from the desktop version of our title works under the emulator, but not on real hardware. (I assume this has to do perhaps with compression? I had to rebuild our graphics as our desktop version uses DXT compression, something it seems most real devices do not.)
-I followed the guide here:
TrueType fonts | MonoGame Documentation and added a spritefont and accompying .ttf file via Content.mgcb with the spritefront set to build and the ttf file copy.
Again everything works like a charm under the emulator but immediately crashes on real hardware when it tries to load any font. I’ve tried different fonts without success.
I feel as if I am perhaps missing something basic. Any advice would be appreciated!
Some guesses are that either your device runs out of memory,
or the texture of the font is too big for the specs of the device.
Move the font as the very first thing you load, and check on the desktop what are the dimensions of font.Texture.Windth|Height.
Thanks for the advice. Unfortunately still no luck. I now have the font the very first thing that loads and the game crashes even faster now
This is what my code currently looks like - it crashes right at the:
font = Content.Load(“fonts\font”); line
ok, you didn’t tell me about the font size, but the font size and character range are reasonably within limits. Do you have trimming enabled?
Do you get are error message/exception/stack trace of the error?
I did try disabling trimming. I also attempted a solution mentioned in this thread:
This can be easily reproduced by creating a new Android project (MonoGame 188.8.131.523, .NET6, Android 31), though I have the same issue with iOS. Add a new SpriteFont to your content (default Arial template is fine), and then try to build a release build (or enable the trimmer/linker on a debug build to actually see the error).
It will crash when attempting to load the SpriteFont with Could not find ContentTypeReader Type
I have tried to set the trim mode to SDK Only. I have tried to add a RootA…
No luck so far. I’ve haven’t setup debugging when running on a real device yet. That’s my next thing to learn about Android development
I really appreciate the advice so far! Thanks!
Are you building your .mgcb with an Android target?