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
\$\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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for your reply! But as you said, its more like a counterproductive solution. \$\endgroup\$ – Nyanko Feb 13 '14 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\$ – craftworkgames Feb 13 '14 at 22:10
  • \$\begingroup\$ Did anything change since then? \$\endgroup\$ – Den Apr 14 '14 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\$ – craftworkgames Apr 15 '14 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.