Refer to the official tutorial:
https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_android.html
1. Software to Download#
OpenJDK 11+
https://adoptium.net/zh-CN/temurin/releases/?version=11
It is recommended to download the compressed package, extract it, and then add the environment variable
JAVA_HOME
The folder where jdk11 is stored, mine is C:\Program Files\Java\jdk11.0.18_10
Android Studio
https://developer.android.google.cn/studio?hl=zh-cn
After installing Android Studio, open
Select sdk 32.0.0 (default for godot is 32) and 30.0.3
Select NDK r23c (23.2.8568313)
Select CMake 3.10.2
2. Generate Key#
A debug keystore needs to be generated. Open cmd, switch to the bin folder where jdk11 is stored, and run the following command
keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12
3. Add SDK Location and Debug Key#
Open Godot, Editor → Editor Settings → Android
Add the AndroidSDK path, default is C:\Users\your_username\AppData\Local\Android\Sdk
The debug keystore location is in the bin folder
Keep the debug keystore user and password unchanged
androiddebugkey
android
4. Install Export Templates#
Export template download link
https://downloads.tuxfamily.org/godotengine/
Select Godot_v4.0-stable_export_templates.tpz from the corresponding version
Project → Install Android Build Template
5. Export Settings#
Project → Project Settings
Make sure to check import STC ASTC
5.1 Debug Export#
In the export settings
Check Use Gradle Build (target SDK can be overridden)
Target SDK is 30
If Use Gradle Build is not checked, the target SDK cannot be overridden, and the default SDK 32.0.0 will be used to export the apk
Check arm64
Fill in the debug key location, user and password as above
Modify the name and unique name, format as shown in the image
Make sure to check signing, otherwise the apk will not install
5.2 Release Export#
If for release
keytool -v -genkey -keystore mygame.keystore -alias mygame -keyalg RSA -validity 10000
User is mygame
, please modify as needed
The key needs to be set by yourself
When using Project Export, do not check Debug Export
Use All Export, click release