一键部署

什么是一键部署?

平台配置正确并且将支持的设备连接到电脑上之后,就可以使用一键部署功能。因为能出错的地方太多了(平台可能没有配置正确、SDK 可能没有正确安装、设备可能配置错了等等),所以最好让用户先知道有这样的功能。

添加 Android 导出预设项并且标记为可执行之后,Godot 就可以检测到有 USB 设备插到了电脑上,并且允许用户在该设备上自动导出、安装、然后运行(调试模式的)项目。这个功能就叫 一键部署

备注

在导出对话框中添加导出模板并标记为可执行后便可使用一键部署。你可以同时将多个导出预设项标记为可执行,但同一平台被标记为可执行的只能有一个。如果你把该平台的第二个预设项标记为可执行,其它预设项的标记会被取消。

支持的平台

  • Android: 将在导出项目时启用调试,并在连接的设备上运行。

    • 请确认已经按照 为 Android 导出 中提到的步骤进行操作,否则不会出现一键部署按钮。

    • 如果你连接的设备超过一台,Godot会询问你想导出项目到哪台设备。

  • HTML5: 将启动本地网页服务器,并打开默认网页浏览器运行导出的项目。

针对包含iOS在内的更多平台的支持在计划之中。

使用一键部署

  • 如果是部署到Android,请在你的移动设备上打开开发者模式,然后在设备设置中启用USB调试。

  • 打开USB调试后,将设备通过USB线连接到PC。

    • 如果你是高级用户,也可以使用无线ADB。
  • 确认目标平台(Android 或者 HTML5)有一个被标记为 可执行 的导出预设项。

  • 如果这些都配置正确并且没有报错,编辑器右上角会出现平台对应的图标。

  • 点击该按钮一键导出到所需的平台。

../../_images/oneclick.png

故障排除

Android

If you can’t see the device in the list of devices when running the adb devices command in a terminal, it will not be visible by Godot either. To resolve this:

  • Check if USB debugging is enabled and authorized on the device. Try unlocking your device and accepting the authorization prompt if you see any. If you can’t see this prompt, running adb devices on your PC should make the authorization prompt appear on the device.

  • Try revoking the debugging authorization in the device’s developer settings, then follow the steps again.

  • Try using USB debugging instead of wireless debugging or vice versa. Sometimes, one of those can work better than the other.

  • On Linux, you may be missing the required udev rules for your device to be recognized.