Noob question - probably

So, I’ve decided to get back in to programming after a long gap. I have a very nearly finished XNA PC game that I want to use to create a finished Android game.

When I run the PC version on Monogame everything works fine, but when I try to run the Android version it deploys to the emulator correctly with no errors but all I get is the cornflower blue screen. Anyone have any ideas why this would be?

Really appreciate any help.

It sounds like you’re deploying an empty Android game, that was created when you create a new Android project. You’ll need to update your GameActivity class, in your Android project, to run your game class.

Keep in mind that it probably won’t work straight across. I don’t know how you set up your game, but if it started life as a PC game it likely uses mouse and/or keyboard input. This won’t work on Android, you’ll need to update your code so that it can use whatever input method is given to it.

How you achieve this is entirely up to you, but as I’m a big fan of SOLID principles, I’d recommend that you create components to handle input and allow your game to take (via its constructor) an interface that represents those components as a dependency.

Your pc entry point can instantiate your game class with a dependency that implements input for PC, and your Android entry point can instantiate a dependency that implements input for Android (and so on).

Thank you very much for replying, really appreciate it.

I did amend the GameActivity class, is the below correct? I did try adding breakpoints to the main class to ensure it was running and they were hit.

Did consider that the error could be down to keyboard input so I disabled it as the code does not require any input to run.

using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Views;

namespace Robot_Jumps
{
[Activity(Label = “RobotJumpsPhone”
, MainLauncher = true
, Icon = “@drawable/icon”
, Theme = “@style/Theme.Splash”
, AlwaysRetainTaskState = true
, LaunchMode = Android.Content.PM.LaunchMode.SingleInstance
, ScreenOrientation = ScreenOrientation.FullUser
, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize | ConfigChanges.ScreenLayout)]
public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var g = new JumpsMain();
RequestedOrientation = ScreenOrientation.Landscape;
SetContentView((View)g.Services.GetService(typeof(View)));
g.Run();
}
}
}

The input stuff wouldn’t prevent the code from running, or show the default screen, it would just mean things wouldn’t work as expected. If that’s disabled, then you wouldn’t have to worry.

What you post looks fine to me, provided that JumpsMain is the entry point for your actual game. If it’s not working, ensure you don’t have a duplicate JumpsMain (check your references) anywhere. This needs to be the same one that your PC project(s) launch.