Search code examples
c#androidxnamonogamexamarin-studio

MonoGame on Xamarin Studio - Issue with Xna?


I want to give a try to MonoGame with Android Studio. I'm actually on a Mac. I'm doing the following tutorial :

https://developer.xamarin.com/guides/cross-platform/game_development/monogame/introduction/part1/

But just after creating the shared project, I had a screen full of missing directives / unnecessary directives like :

"Using directive is unnecessary" "the type or namespace name 'XXXXX' could not be found"

I tried to add the "MonoGame.Framework.Android" package to the android part of the project but it did not changed a single thing.

I tried some researches but I have some difficulties to describe my problem, because I don't really understand it. I'm not sure, but I think it's coming from references.

  • Did you experienced the same issue ?
  • I think I miss some references (especially Xna), how do I add them on Xamarin Studio ?
  • Is the Monogame Add-In deprecated ?

Solution

  • Ok it's done!

    It was a linking problem : i did not have the needed references, I needed to install Mono and MonoGame, not just MonoGame AddIn.

    Here is my solution:

    1 - Uninstall the MonoGame AddIn

    2- Uninstall Xamarin (yeah it's extreme)

    3 - Install Mono http://www.mono-project.com/

    4 - Install MonoGame http://www.monogame.net/downloads/

    5 - Re-Install Xamarin

    6 - Activate MonoGame AddIn -> it's already there

    7 - Create a SharedProject, then modify the "OnCreate" method in the Android part :

    protected override void OnCreate(Bundle bundle)

    {

            base.OnCreate(bundle);
            var g = new Game1();
            SetContentView((View)g.Services.GetService(typeof(View)));
            g.Run();
    

    }

    8 - Profit, enjoy your MonoGameSample.

    thanks to @hankide for giving his help.

    This link helped me a lot:

    http:// blog.jamie.ly/software/2013/04/23/setting-up-a-monogame-mac-application-with-xamarin-studio.html

    PS : i don't have enought reputation to post more than 2 links so the last one have a space between "http://" and "blog.jamie"