2
\$\begingroup\$

I'm quite new to Monogame and PCL, but I hope someone can help me with my question.

I have a Monogame/Android project with references a PCL which targets .NET 4.5, iOS and Android. The PCL has content files suchs as SpriteFont and Texture2D. They are set to "Content", "Always copy" and are .xnb files. The problem is when I start my Android game I get a "asset not found" exception for the content in the PCL. When I launch my Windows game it works all fine.

To begin with, can I have content files in a PCL and is that good practice?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

That's a good question. Unfortunately, I haven't got an ideal solution, but I do have a similar setup to you with a PCL and an Android project. As you can see, I have the content in the PCL set to "Content", "Copy if newer".

In the Android project I have added the same files under the Asset/Content folder as links to the original files and set their properties to "AndroidAsset". It works just fine, but it does mean I have to keep add content to both projects which is slightly annoying.

Portable Content Example

I'd be interested to know if a better solution to this problem comes up.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks for your reply! But as you said, its more like a counterproductive solution. \$\endgroup\$
    – Nyanko
    Feb 13, 2014 at 11:25
  • \$\begingroup\$ It is, but it's better than nothing. What I normally do is make the game as a Windows GL project then every so often I do a quick port to Android by relinking all the Content. It may not be perfect but it's only a 5 minute job. You still get most of the benefits of a PCL and it sure beats code sharing. \$\endgroup\$ Feb 13, 2014 at 22:10
  • \$\begingroup\$ Did anything change since then? \$\endgroup\$
    – Den
    Apr 14, 2014 at 20:10
  • \$\begingroup\$ Things are changing slowly. If you are interested in portable MonoGame follow this guys blog.. darkgenesis.zenithmoon.com/monogame-3-2-nuget-packages-are-go \$\endgroup\$ Apr 15, 2014 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .