Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
为 Android 平台编译¶
参见
这个页面描述的是如何从源码编译 Android 导出模板二进制。如果你想要找的是导出项目到 Android,请阅读 为 Android 导出。
注意¶
对于大多数情况, 使用内置部署程序和导出模板就足够了. 手动编译Android APK对于部署程序的自定义版本或自定义程序包最有用.
此外, 在尝试构建自定义导出模板之前, 你仍然需要按照 为 Android 导出 教程中提到的步骤进行操作.
需求¶
要在Windows, Linux或macOS下进行编译, 需要以下内容:
SCons 3.0+ 构建系统.
Android SDK (命令行工具就足够了).
所需的 SDK 组件将被自动安装。
- 在Linux上,
do not use an Android SDK provided by your distribution's repositories as it will often be outdated.
Gradle(如果缺少,将自动下载并安装)。
JDK 17 (either OpenJDK or Oracle JDK).
You can download a build from ojdkbuild.
设置构建系统¶
Set the environment variable
ANDROID_HOME
to 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.在此文件夹中安装必要的SDK组件:
通过运行以下命令接受SDK组件许可证, 其中
android_sdk_path
是android SDK的路径, 然后用y
回答所有提示:
cmdline-tools/latest/bin/sdkmanager --sdk_root=<android_sdk_path> --licenses
运行以下命令完成安装, 其中
android_sdk_path
是Android SDK的路径.
cmdline-tools/latest/bin/sdkmanager --sdk_root=<android_sdk_path> "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;3.10.2.4988404"