Export native games to Android

The latest version of GDevelop has an experimental feature allowing to compile a native game for Android. Compared to HTML5 games built with Intel XDK, the games natively built for Android have better performances and can use more extensions.

Currently, only the base features (including “Sprites”), “Text objects”, “Tiled Sprite objects”, “Panel Sprites (9-patch) objects”, “TileMap object”, “Physics behavior”, “Top-down movement”, “Destroy outside screen behavior”, “Platformer behavior” and “Platform behavior” are compatible with the android export feature. The other extensions will be available soon!

Tools installation

This section explains the installation of all required tools used to compile a game to Android.

CMake

For Windows, download CMake on the official website: https://cmake.org/. Be sure to check “Add CMake to the system PATH for all users” ou “Add CMake to the system PATH for the current user”.

For Linux, check the packages available for your distribution.

Apache Ant

Download Ant for Windows on the official website. Extract the compressed file somewhere on your computer.

For Linux, use again the package manager of your distribution.

JDK

The Java Development Kit is needed to build Android apps:

For Windows, download it on site officiel and install it.

For Linux, you can install the package called openjdk-7-jdk or openjdk-8-jdk (this can varies according to your distribution).

Android SDK

The Android SDK contains the tools that are specific to Android development. For Windows and Linux, download it on the website by selecting your operating system in the section called “Get just the command line tools” on this SDK download page.

Launch the installer.

At the end, launch “SDK Manager.exe” (This file is inside the folder where the SDK was installed) on Windows or the script called “android” inside the “tools” folder on Linux. Wait a bit for this window to appear:

Uncheck everything, we're going to select only what we need.

Select “SDK Platform”, “Source for Android SDK” in the category 4.4.2, API 19. If you want to launch the game in an emulator later, select “System images” in “ARM EABI v7a System image” and “Intel x86 Atom System image”.

The game will works on older/newer versions of Android even if we select a particular version of the “API”.

Then in “Tools”, check “Android SDK Tools”, “Android SDK Platform-tools” et “Android SDK Build-tools” (the most recent one). Finally, for Windows only, in “Extras”, choose “Google USB Driver”.

You can now click on Install X packages….

Android NDK

To compile games exported by GDevelop, you also need the Android NDK (a software development kit for native apps). GDevelop currently supports the r11c version of the Android NDK. You can download this version by following these links:

It seems that the 32 bits NDK causes some problems when compiling a game for Android. If you have Windows 32 bits, you may not be able to export your game to Android.

SFML

Download this file and extract it into the “sources” folder inside the folder where you extracted the Android NDK.

Compile the game

These steps should be done each time you want to build a game for Android.

Start by exporting your game in GDevelop. In the File menu, choose “Export for Android (experimental)” and export the game in a folder.

Open a terminal and go to the folder where the game was exported. For example, on Windows: cd C:\Users\Florian\MyExportedGame

Update the PATH by doing :

Windows :

In the terminal enter "GDEVELOP_FOLDER\CppPlatform\MinGW32\mingwvars.bat" with GDEVELOP_FOLDER being C:\Program Files (x86)\GDevelop on Windows 64 bits and being C:\Program Files\GDevelop on Windows 32 bits.

Type in the command line prompt: PATH="PATH_TO_ANT\bin";"PATH_TO_NDK";"PATH_TO_SDK\tools"; "PATH_TO_SDK\platform-tools";%PATH% with PATHTOANT being the folder where Ant was extracted, PATHTONDK the folder to the Android NDK and PATHTOSDK the path to the Android SDK. (Beware, be sure to use \ and not /, and don't forget the quotes!)

Linux :

In the terminal: export PATH="PATH_TO_NDK":"PATH_TO_SDK/tools":"PATH_TO_SDK/platform-tools":$PATH

with PATHTONDK the folder of the Android NDK and PATHTOSDK the path to the Android SDK. (Beware, be sure to use /, don't forget the quotes and the separator between the paths is :!)


Stay in the folder of the game and type these commands in this order:

android update project --target "android-19" --path .

ndk-build

ant debug

Run the game

The game is generated as an .apk file, called NativeActivity-debug.apk, available in the bin directory. To run the game, you can send the APK file to your Android phone and launch it. To allow the installation, you must go in your Phone Settings > Security and activate Unknown sources. This will enable you to install the APK file even if it is not yet registered on the Google Play Store.