Work in progress
Godot documentation is being updated to reflect the latest changes in version
4.0. Some documentation pages may
still state outdated information. This banner will tell you if you're reading one of such pages.
The contents of this page are up to date. If you can still find outdated information, please open an issue.
Compiling for Android¶
This page describes how to compile Android export template binaries from source. If you're looking to export your project to Android instead, read Exporting for Android.
In most cases, using the built-in deployer and export templates is good enough. Compiling the Android APK manually is mostly useful for custom builds or custom packages for the deployer.
Also, you still need to follow the steps mentioned in the Exporting for Android tutorial before attempting to build a custom export template.
For compiling under Windows, Linux or macOS, the following is required:
SCons 3.0+ build system.
Android SDK (command-line tools are sufficient).
Required SDK components will be automatically installed.
- On Linux,
do not use an Android SDK provided by your distribution's repositories as it will often be outdated.
Gradle (will be downloaded and installed automatically if missing).
JDK 11 (either OpenJDK or Oracle JDK).
You can download a build from ojdkbuild.
To get the Godot source code for compiling, see Getting the source.
For a general overview of SCons usage for Godot, see Introduction to the buildsystem.
Setting up the buildsystem¶
Set the environment variable
ANDROID_SDK_ROOTto point to the Android SDK. If you downloaded the Android command-line tools, this would be the folder where you extracted the contents of the ZIP archive.
Install the necessary SDK components in this folder:
Accept the SDK component licenses by running the following command where
android_sdk_pathis the path to the Android SDK, then answering all the prompts with
tools/bin/sdkmanager --sdk_root=<android_sdk_path> --licenses
Complete setup by running the following command where
android_sdk_pathis the path to the Android SDK.
tools/bin/sdkmanager --sdk_root=<android_sdk_path> "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;22.214.171.12488404"
To set the environment variable on Windows, press Windows + R, type "control system", then click on Advanced system settings in the left pane, then click on Environment variables on the window that appears.
To set the environment variable on Linux or macOS, use
export ANDROID_SDK_ROOT=/path/to/android-sdk where
/path/to/android-sdk points to
the root of the SDK directories.
Building the export templates¶
Godot needs two export templates for Android: the optimized "release"
android_release.apk) and the debug template (
As Google will require all APKs to include ARMv8 (64-bit) libraries starting
from August 2019, the commands below will build an APK containing both
ARMv7 and ARMv8 libraries.
Compiling the standard export templates is done by calling SCons from the Godot root directory with the following arguments:
Release template (used when exporting with Debugging Enabled unchecked)
scons platform=android target=template_release arch=armv7 scons platform=android target=template_release arch=arm64v8 cd platform/android/java # On Windows .\gradlew generateGodotTemplates # On Linux and macOS ./gradlew generateGodotTemplates
The resulting APK will be located at
Debug template (used when exporting with Debugging Enabled checked)
scons platform=android target=template_debug arch=armv7 scons platform=android target=template_debug arch=arm64v8 cd platform/android/java # On Windows .\gradlew generateGodotTemplates # On Linux and macOS ./gradlew generateGodotTemplates
The resulting APK will be located at
If you want to enable Vulkan validation layers, see Vulkan validation layers on Android.
Adding support for x86 devices¶
If you also want to include support for x86 and x86-64 devices, run the SCons
command a third and fourth time with the
arch=x86_64 arguments before building the APK with Gradle. For
example, for the release template:
scons platform=android target=template_release arch=armv7 scons platform=android target=template_release arch=arm64v8 scons platform=android target=template_release arch=x86 scons platform=android target=template_release arch=x86_64 cd platform/android/java # On Windows .\gradlew generateGodotTemplates # On Linux and macOS ./gradlew generateGodotTemplates
This will create a fat binary that works on all platforms. The final APK size of exported projects will depend on the platforms you choose to support when exporting; in other words, unused platforms will be removed from the APK.
Cleaning the generated export templates¶
You can use the following commands to remove the generated export templates:
cd platform/android/java # On Windows .\gradlew cleanGodotTemplates # On Linux and macOS ./gradlew cleanGodotTemplates
Using the export templates¶
Godot needs release and debug APKs that were compiled against the same version/commit as the editor. If you are using official binaries for the editor, make sure to install the matching export templates, or build your own from the same version.
When exporting your game, Godot opens the APK, changes a few things inside and adds your files.