Godot 3.1 – How to export to Android in simple steps

Image that displays Android and godot logo for export

Building and setting up the export for Android in Godot can feel a bit intimidating for newcomers, however you only have to do this once. Afterwards you are able to send a build to your mobile device in a matter of seconds, by just pressing a button and having a mobile device attached through USB.

The first thing you have to do in Godot is ensure you have the Export Templates setup. You can do this by going to Editor/Manage Export Templates in Godot. Afterwards you click on the download button. Afterwards you go to Editor/Editor Settings select the Export tab, and Android. From there you can set the locations for the Adb, Debug Keystore and Jarsigner locations. You can get the Adb from the Android SDK, the debug keystore is made using the JDK keytool which is downloadable through Github or Oracle.

Installing the export templates

In order to install the export templates, navigate to the top window and select Editor. From there you can select Manage Export Templates. Afterwards you click on the download button like the image below. And you then select Official 3.1.2 [HTTPS]. Note that this can change based on the version you are currently using of Godot. Sometimes when the link is not available, you have the option to install a template through a file. You can find older export templates and releases here. You can also get the latest Github release with export templates on the Unofficial Godot Engine builds site by Hugo Locurcio. Do note tough that the export template needs to match the current Godot version.

The images below show you how to do it visually.

Godot setting export templates for Android
Here you can see how to navigate to the Manage Export Templates selection
Godot downloading active export template for Android
After opening the Export Template Manager menu, click on Download
Godot downloading an export template using the official link
Installing the export templates using the official link

After the download is done, the export templates get installed automatically. Kind in mind that you will have to repeat this process for each new version you have to install. This step is fairly easy tough, I think we can manage this.

Downloading Android SDK and the JDK

In order to setup these things you have to download the Android SDK and you have to download OpenJDK or OracleJDK. It is recommended to stay at JDK version 8 or higher, as lower versions may have issues. I personally installed java-1.8.0-openjdk, the third option on the OpenJDK github page.

Creating a key using the command line

After you have installed both the SDK and OpenJDK. You should be able to use this command with the command line. For windows you can go to the command like by opening the search bar (pressing the windows button) and searching for CMD and pressing enter. You can then copy the following command into the command line.

keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999

For Windows 10, you can then find the keystore in “C:\Users\YourUserName”, it is named “debug.keystore”. Make sure to keep the folder to this location available, since we will need it later on.

If you are certain you have installed both the JDK and SDK and the command does not work due to it not being recognized, then there is a chance the system variables are not setup properly. You can find a guide here that shows you how to point the system variables to the JDK folder.

Navigating to the Android export editor settings

In order to start setting up the references, you have to navigate to Editor/Editor Settings

Shows where the Editor Settings button is in the Godot Engine
As you can see, the Editor Settings is located under the Editor tab

Afterwards, you scroll down on the left side until you get to the Export tab, and you select Android

Displays how to find Android settings in the Editor Menu of Godot
All the settings for the Android Export

Setting up the location for the Adb

For Adb you have to go to the SDK folder and then into the “platform-tools” folder. For windows 10 this is generally located at:

C:\Users\UserName\AppData\Local\Android\Sdk\platform-tools

If you are unsure where to find the Sdk folder, open up the Android SDK and navigate to the new project settings like the image below.

Example of how to find the android Sdk location on your computer using Android Studio

Setting up the location for the Jarsigner

The Jarsigner is located in the OpenJDK or OracleJDK folder you have unpacked previously.
When installing the OpenJDK on my device it was located at:

C:\Program Files\ojdkbuild\java-1.8.0-openjdk-1.8.0.232-2\bin

Setting up the location of the Debug Keystore

This keystore was made earlier in this article, once created, it gets placed in the User folder:

C:\Users\UserName

Getting ready to make a build

Navigate to Project/Export to go to the export window

Add a new export preset by pressing the Add… button and selecting Android

How to add a new present in the export options

Now finally, set the Unique name and name of the package.
How I generally name the Unique name is com.myComp.ProductName and the name is what will be displayed on your android device. So that should be equal to your product name. Spaces are allowed.

How to setup the package Unique name and general name

Making your build

There are two ways to make a build. One is to press the Export Project button in the export window. The other option is to use the icon that is available in the editor window. Personally I prefer using the icon, as this will automatically install the build to the phone. Just make sure it is connected to your computer using USB with USB Logging on, using developer mode. If you are unsure how to enable developer mode. Then you have to google “How to enable developer mode <your device name>”.

How to quickly build the project to your device

After pressing the button above, you will have the game running in no time on your device.

Releasing the build to Google Play Games

When exporting a build to Google Play Games, it is important to use a release keystore. This is because the debug keystore is merely meant for development and testing purposes. It is also not advised to release games using a debug keystore.

Signing a keystore is like branding the application with your credentials. And it is possible to assign the same keystore to multiple applications. The debug keystore has base credentials.

Eventually when you want to release to the play store you use a Release keystore. It is important that you keep this key safe, since you will only be able to push updates if you sign the application with the initial key. Preventing malicious users from pushing harmful code in case the account gets stolen.

How to make a release keystore?

Again, like the steps above to create a debug key, there is a parameter to create a release key. Make sure to set yourKeyAlias to an alias of your choice.

keytool -genkey -v -keystore release.keystore -alias yourKeyAlias -keyalg RSA -keysize 2048 -validity 10000

After doing this, you will get the question for a password. Make sure to note it down, because losing it means losing your key. And it has happens to people before that they had to republish a game on Google Play due to this.

After entering the password twice, you will get a lot of questions such as first/last name. Organisational unit, etc. You can leave these blank. At the end you get a question asking if it is all correct, you then type in yes. After creating the key, you may get this message:

Warning:
The JKS keystore uses a proprietary format. 
It is recommended to migrate to PKCS12 which is an industry standard format using
 "keytool -importkeystore -srckeystore release.keystore -destkeystore release.keystore -deststoretype pkcs12".

Doing this will change the keystore into a file with the “.pfx” extention, from what I’ve seen godot only accepts the .keystore format. So we can ignore this for now.

Set the reference in the export

Finally we set the reference to our release key in the export like the image below.

DIsplays how to set the release keystore for android export

Also, when you have pressed export, do not forget to toggle this off, else it will still sign it using the debug key!

Disable export with debug when saving

Thank you for reading, and I hope it has helped you. If you have interest in implementing ads into your game and you happen to be using Godot 3.2, then I recommend reading “How to integrate Google Ads (Admob) for Android”

Copyright © 2024 Godot Learn