When building a project for the Android target, it's not always possible to have a range of physical devices at hand to test different screen sizes or processing power, which is where emulation and Android Virtual Devices (AVDs) come in handy. An AVD is an virtual machine running Android on an emulated set of device specifications, including memory, screen size, CPU, etc... and you can target these from GameMaker and test projects on them just as you would a physical device (to a reasonable degree!). In this article we explain how to set up an AVD for use in this way.
For more information on AVDs see here: Create And Manage AVDs
Note that if you do not own any real Android devices, we do not recommend an emulator as the only testing you do before you do a store submission! Performance levels can be much lower on a phone than on your beefy PC, so your game might kill low-end phones and you'd never know until you started getting crash reports back from customers.
When Using Android Studio (PC and Mac)
If you have installed Android Studio on your Mac or PC then you have access to the AVD Manager. This program permits you to create and run different Android Virtual Devices, and if you have followed the Android Setup Guide and used a custom install for Android Studio then it should be installed and ready to use, so you can skip down to the section on Using The AVD Manager. If you performed a default install, however, you will need to take some additional steps...
If you have performed a default install of Android Studio then before you can open the AVD manager you will first need to ensure that you have installed Intel HAXM, as the different device emulators require it to run.
Note that HAXM may not be required on your machine. If your Virtual Devices do not work without HAXM, then try installing it.
To install this, you need to first go back to the SDK Manager and then in the SDK Tools section select Intel x86 Emulator Accelerator (HAXM installer):
Once you click Apply this will be added to the SDK Tools and you can close the SDK Manager. This has simply downloaded the HAXM installer, but hasn't actually installed it on your machine yet. We'll do that in the next step.
IMPORTANT: For Windows PC users, before you can use HAXM you must have disabled Hyper-V (if you have it installed), and also ensure that HAXM will work on your machine. For more information on HAXM please see here.
Using The AVD Manager
To get to the AVD Manager, you now need to create a new, blank, project in Android Studio (just create a project and click through on all the default values). Once the project IDE is open you can click on the Open AVD Manager button at the top of the window:
This will open the AVD Manager and if you haven't already installed HAXM (ie: you performed a default install and have downloaded the HAXM installer as outlined above), then you will be prompted to install HAXM now. Simply click the link shown and follow the onscreen instructions before continuing.
By default the AVD Manager will have one or more devices previously created for you and you can simply start any one of them (by clicking the play button) for it to be available for use in GameMaker:
If you don't have any AVDs, you can create new ones. Make sure your system image uses ABI x86_64 instead of just x86.
Now your AVD is running you can go back to GameMaker and skip to the section Connecting To An AVD, below.
When Using Command Line Tools (PC Only)
If you are not using Android Studio and have instead opted to use the command line tools, or have an existing command line tools installation, then you should be able to open the AVD Manager directly from GameMaker by clicking the "Run AVD" button in the Target Manager devices window.
This will open the AVD Manager where you can create and then run your virtual device (or select and run one of the default devices). You can also open the AVD manager by first opening the SDK Manager and then going to Tools > Manage AVDs.
IMPORTANT! The command line tools require that your PC has HAXM installed and that Hyper-V is disabled before you can use an AVD. This is the VM that will be used to create your AVD's and can be downloaded here: Intel Hardware Accelerated Execution Manager.
In the AVD Manager you can create a new device or use one of the default ones supplied, but whatever you do, you need to start the AVD before trying to connect with GameMaker (simply click the "Start" button from the AVD Manager).
Connecting To An AVD
Once the AVD is running, you can open the Target Manager in GameMaker and then go to the devices preferences for Android and click the "Detect Device" button and the new AVD should appear in the list of available devices:
Note that when filling-in Game Options > Android for the project you must select the x86_64 Architecture when targeting an AVD, otherwise your package can't be loaded in the emulator.