Jadon Leininger
In order to build and run on an Android device, virtual or physical, first you must install the proper tools. In this case, that's the Android SDK and ADB (Android Device Bridge). This can be installed as a standalone or bundled with Android Studio. I chose to install Android Studio as it includes an easy to use GUI for the Android SDK manager and AVD (Android Virtual Device) manager.
Follow this tutorial: https://www.androidcentral.com/installing-android-sdk-windows-mac-and-linux-tutorial
Go here and click the big DOWNLOAD ANDROID STUDIO button.
After Android Studio is installed, open it up and you should be greeted by a welcome screen:
On the bottom right corner, you should see an icon that looks like this:
Click it and choose the SDK Manager option.
First, find the version of Android that your device is running. For me (Samsung Galaxy S9), that means going to Settings > About phone > Software information > Android version. For other devices, try the instructions listed here: https://www.howtogeek.com/230737/how-to-find-out-which-version-of-android-you-have/.
Once you have the device's Android version, go back to the SDK Manager:
Click the checkbox next to your version and then click Apply.
Finally, click OK in the confirm popup and your version of Android platform will be installed.
If you are testing on a virtual device, usually taking the latest Android version is preferred. After that install finishes, you are ready to move on to the next step.
Android runs Java, and Godot needs the jarsigner package from the Java JDK to install your app on a device. To install the Java JDK follow one of the instructions listed below.
For Linux:
https://iwillteachyoukotlin.com/start/jdk-linux/
For Mac:
For Windows:
https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html
Next, it's time to configure Godot for Android export.
First, open Godot and click the Editor > Editor Settings option:
Scroll down or search for Android under the Export heading on the left side:
You should see 3 blank text boxes on the top of the dialog under the search bar Adb, Jarsigner and Debug Keystore. These are the critical paths Godot needs to export for Android.
To find the install locations for the first 2 path text fields, open a terminal window and enter:
which adb
followed by:
which jarsigner
NOTE: The above command worked great for me in MacOS, but not on my personal box running Linux Mint. The command returned the same path as MacOS, and the jarsigner package was there but Godot did not like that one, displaying an error message of OpenJDK jarsigner not configured in the Editor Settings. Instead, I had to manually locate it in /opt/java/jdk1.8.0_181/bin/jarsigner.
The 2 paths returned from each call are the install locations for each packages. Copy and paste each path into it's respective text field.
Finally for the Debug Keystore field, you'll need to find or create a debug.keystore file for the app. If you have ever installed an app in debug mode in Android Studio, you likely have one in your ~/.android folder (mac/linux). If you can't find it or need to create a new one, enter this into the terminal:
keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999
Copy the path to the debug.keystore into the proper field and close the Export Settings dialog.
The last step before being able to install your app to an Android device is adding a runnable export.
To do this, go back to the Project dropdown and this time select the Export option. This will open the Export dialog, there click Add... > Android to add the Android runnable:
In this dialog, we can add details about app. There are many different settings that you can enable and disable, but only 1 is required for exporting.
Package > Unique Name: This can be any valid string you want (Godot will yell at you if it's not), but since Android uses it as a unique identifier, it should be something unique to you. Using your name in a reverse url format is convention. Ex: com.{yourname}.{appname}.Change that to be something valid and you can accept all the defaults on the other settings for now. We now have what we need to move on to the next step.
Finally, you'll need to download an export template for running the app the first time. Click the Manage export templates button which should bring you to the Export templates dialog:
Click Download next to the missing template version and your download should start. After that downloads and installs you are ready to run your app!
Plug in your physical or start up your virtual device. You should see a little Android icon appear next to the Play Scene icon:
Click it, select your device and the app should install to your device and start running automatically.
Congratulations! You are now able to export and run on an Android device through Godot. Have fun and build something awesome!
The file that Godot generates with your Android export configuration (export_presets.cfg) does contain sensitive information about your app that you don't want just anybody to see. Be careful where you save it!
When exporting your project for production, be sure to unselect Export With Debug in the Project > Export > Export Project dialog.
More info about exporting is located in the official Godot documentation, https://docs.godotengine.org/en/3.1/getting_started/workflow/export/exporting_for_android.html.
Godot is an amazing open source software for making games quickly and with relative ease. If you love Godot as much as I do, please consider donating to the project so that it can continue to improve and grow https://godotengine.org/donate.
Please leave questions or comments in the Comments section below and thank you for stopping by!
Godot Logo (C) Andrea Calabró Distributed under the terms of the Creative Commons Attribution License version 3.0 (CC-BY 3.0) https://creativecommons.org/licenses/by/3.0/legalcode.