Set up the Android Game Development Extension on a Windows computer and run a sample Visual Studio C++ project on an Android device or emulator.
Follow the steps in this section to prepare your Windows computer for installation of the extension:
Download and install one of the supported versions of Visual Studio:
Install the extension
Follow the steps in this section to download and install the Android Game Development Extension:
Close all instances of Visual Studio.
Download the latest extension installer and samples from the Downloads page.
From your download location, double-click the installer. The installer takes several minutes to complete.
If you have more than one version of Visual Studio installed, select the versions that you would like the extension to be installed for.
Click Finish to complete the installation.
Install the Android SDK and NDK
You can install the Android SDK and the Android Native Development Kit (NDK) with Android Studio or the Android Game Development Extension. To install the SDK and NDK from the extension, use the SDK Manager, which is located in the extension toolbar of Visual Studio.
When installing the NDK, make sure to use the NDK (Side by side) checkbox so that the extension can locate it. You must install an NDK version that is supported by the extension (see NDK revision history).
To install the SDK to a different location than the default, set the
ANDROID_SDK_ROOT environment variable on your computer:
- Ensure that Visual Studio is closed.
- In Windows Search, search for
- Select Edit the system environment variables.
- Click Environment Variables.
- Under User Variables, click New.
- In the Variable Name box, type
- In the Variable Value box, enter the path to the Android SDK.
- Reboot your computer.
The location of the SDK cannot be modified using the SDK Manager window as this environment variable is the only source-of-truth for the SDK location.
Run the sample
Follow the steps in this section to run the Teapot sample in an emulator and then on a physical Android device.
Configure the platform
Start Visual Studio if it is not already running.
Unzip the samples zip file into a directory of your choice. The following samples are included:
Open the samples directory. Select File > Open > Project/Solution and navigate to
Select an Android platform:
- Select Build > Configuration Manager.
- Under Active solution platform, select Android x86.
Two Android platforms are already configured in the sample (you can add more Android platforms later).
Make sure the sample project has the Android SDK and NDK properties configured:
Figure 1. Android platform properties
In the Solution Explorer, right-click GameApplication and select Properties.
Select the General properties tab and find the Platform properties for Android.
Select the Android Packaging properties tab.
Figure 2. Android packaging properties
You can change the output APK name and directory from this tab. Note that some of the Android configuration properties are defined in the property pages and are passed to Gradle. For example, the APK name property
MSBUILD_ANDROID_OUTPUT_APK_NAMEpasses this name to the app
Set up the emulator
Start AVD Manager from the extension toolbar in Visual Studio. Configure a virtual device and then run it in the Android Studio emulator.
- In the Android Virtual Device Manager, click Create Virtual Device.
- Choose a device definition (for example, Pixel 2).
- Select a system image. You should select an x86 ABI because this architecture performs faster in the emulator.
- Verify the configuration and click Finish.
Start the virtual device by clicking the Run button in the Android Virtual Device Manager.
In Visual Studio, the virtual device type should appear next to the Start Debugging toolbar button. Click Start Debugging to launch the Teapot sample app on the device. It may take a few moments for the debugger to attach to the app. You can rotate the teapot by dragging your cursor across it.
Figure 3. Teapot sample running on an Android emulator
Set up the device
To run the sample on a physical Android device, you probably need to create a new Android platform in the project. This platform must match the architecture of the device. To create a new platform, do the following in Visual Studio:
- Select Build > Configuration Manager.
- Under Active solution platform, select <New>.
Type one of the following for the new platform:
- Android armeabi-v7a
- Android arm64-v8a
- Android x86
- Android x86_64
In the Copy settings from box, select None.
Connect an Android device to your computer using a USB cable. The device type should be shown next to the Start Debugging toolbar button.
Figure 4. Connected Android device shown next to the Start Debugging toolbar button
If the device type is not shown, check the following:
- Developer options and USB debugging are enabled on the device.
- The USB cable is connected from the device to the computer.
- The USB cable supports a data connection (and not just power).
- Android Debug Bridge (adb) is running. adb is installed with Android Studio.
- The platform selection matches the ABI of your device.
Click the Start Debugging toolbar button to launch the sample teapot app on the device. It may take a few moments for the debugger to attach to the app. Once it is attached, you can rotate the teapot by dragging your finger across it.
The following are some frequently asked questions about the Android Game Development Extension.
Where are the logs for the plugin located?
You can open the log file for the plugin using the Open Logs icon in the Android Game Development Extension toolbar.
Why is the plugin looking in the wrong location for adb?
The plugin looks for the location of the SDK using the following logic:
public static string GetAndroidSdk() => Environment.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? Environment.GetEnvironmentVariable("LocalAppData").Resolve(@"Android\Sdk");
What environment variables does the plugin use?
The plugin uses the following environment variables:
To use your own project with the extension, you must configure it according to the project configuration guide.