Android

Introduction

FlatRedBall and Glue support game development on Android devices. This section will show you how to make FlatRedBall Android games.

Prerequisites

FlatRedBall Android game development requires a Windows PC, XNA, and Glue just like regular PC game development. Visual Studio is necessary if you plan on creating PC/Android synced projects.

Since FlatRedBall requires using the C# programming language, FlatRedBall Android development requires using Xamarin. The Xamarin license for iOS and Android is free. For more information, see the Xamarin store page here: https://store.xamarin.com/

An Android emulator is necessary for testing games on your PC. We recommend Xamarin’s Android Player (free) or the Genymotion emulator (free for non-commercial projects). Note that Microsoft also offers an Android emulator, but it requires a Pro/Enterprise installation of Windows, and Hyper-V capable hardware.

Primary Android vs. synced Android projects

Glue supports creating a primary Android project as well as a synced Android project.

A primary Android project refers to a situation where a single solution file (.sln) is created. This solution file can be opened in Xamarin Studio or in Visual Studio.

A synced Android project refers to a situation where two solution files are created – one for PC and one for Android. The PC project is developed as a regular FlatRedBall PC (desktop) project in Visual Studio. Glue will generate Android project, and it will keep it in sync with the PC project automatically.

Benefits to creating a primary Android project:

  • Shorter initial setup
  • Less hard drive memory usage
  • Simpler file structure

Benefits to creating a synced Android project:

  • Superior debugging support on PC platforms when compared to Android debugging
  • Faster execution of a project as compared to deploying to an emulator or physical device
  • Allows multiple team members to develop and run the project without installing Xamarin
  • Improved iteration speed through edit-and-continue and automatic content reloading at runtime.

For more information on Glue synced projects, see the Glue synced project page.

Creating a primary Android project

Creating an Android project is essentially identical to creating any other platform:

  1. Open Glue
  2. Select File->New Project
  3. Select the Empty Projects category
  4. Select the Android option
  5. Enter a project name
  6. Click “Make my project!”

createandroidproject2

Click the Visual Studio icon to open the project in Visual Studio:

Now that the project is in Visual Studio, you can develop an Android game the same as if you were making a PC game, including using Glue.

To launch the game:

  1. Open your Android emulator of choice (such as the Xamarin Android Player)
  2. Verify that the Play button in Visual Studio has the desired emulator selected. Note that if a physical Android device is connected to your computer and is set up for debugging, then Visual Studio will detect it as a deployment option.
  3. Press the Play button

 

RunningGenymotion.png

Creating a synced Android project

Synced Android projects are created just like any other synced project. The first step is to create a regular Windows Desktop project. Once the project is created a new synced Android project can be created as follows:

  1. Open Glue
  2. Select File->”New Synced Project”
  3. Select the Android option
  4. Enter a project name
  5. Click “Make my project!”

A synced project will be created which can be opened in Xamarin Studio. It can be executed with the same steps shown above.

Troubleshooting

Unfortunately deploying to Android can be fickle at times, and sometimes no errors are provided.

App crashes immediately

If your app crashes immediately without a call stack, then you may want to try the following:

  • Does the app work on Android hardware? Sometimes an app will not work on emulator but will work on hardware
  • Have you tried creating a Xamarin Forms project? Xamarin Forms projects can be created with templates which are maintained by Xamarin, so they are likely to eliminate common problems in template setup. If a Xamarin Forms project doesn’t work, then that might mean that prerequisites are not properly installed.