Gradle builds for Android

Godot provides the option to build using the gradle buildsystem. Instead of using the already pre-built template that ships with Godot, an Android Java project gets installed into your project folder. Godot will then build it and use it as an export template every time you export the project.

出于某些原因, 你可能想要这样做:

  • 在构建项目之前对其进行修改.

  • 添加与你的项目一起构建的外部SDK.

Configuring the gradle build is a fairly straightforward process. But first you need to follow the steps in exporting for android up to Setting it up in Godot. After doing that, follow the steps below.

Set up the gradle build environment

Go to the Project menu, and install the Gradle Build template:

../../_images/gradle_build_install_template.webp

确保已下载导出模板. 如果没有, 此菜单将帮助你下载它们.

A Gradle-based Android project will be created under res://android/build. Editing these files is not needed unless you really need to modify the project.

Enabling the gradle build and exporting

When setting up the Android project in the Project > Export dialog, Gradle Build needs to be enabled:

../../_images/gradle_build_enable.webp

从现在开始, 尝试导出项目或一键部署会调用 Gradle 构建系统来生成新的模板(每次都会出现这个窗口):

../../_images/gradle_build_gradle.webp

生成的模板将在以后自动使用, 因此不需要进一步的配置.

备注

When using the gradle Android build system, assets that are placed within a folder whose name begins with an underscore will not be included in the generated APK. This does not apply to assets whose file name begins with an underscore.

For example, _example/image.png will not be included as an asset, but _image.png will.

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.