deploying_to_android.rst 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .. _doc_deploying_to_android:
  2. Deploying to Android
  3. ====================
  4. Setup
  5. ------------
  6. Most standalone headsets run on Android and OpenXR support is making its way to these platforms.
  7. Before following the OpenXR-specific instructions here, you'll need to first setup your system to export to Android in general, including:
  8. - Installing OpenJDK 17
  9. - Installing Android Studio
  10. - Configuring the location of the Android SDK in Godot
  11. See :ref:`doc_exporting_for_android` for the full details, and return here when you've finished these steps.
  12. .. warning::
  13. While the Mobile Vulkan renderer has many optimizations targeted at mobile devices, we're still working out the kinks.
  14. It is highly advisable to use the compatibility renderer (OpenGL) for the time being when targeting Android based XR devices.
  15. Gradle Android build
  16. --------------------
  17. .. note::
  18. Official support for the Android platform wasn't added to the OpenXR specification initially resulting in various vendors creating custom loaders to make OpenXR available on their headsets.
  19. While the long term expectation is that all vendors will adopt the official OpenXR loader, for now these loaders need to be added to your project.
  20. In order to include the vendor-specific OpenXR loader into your project, you will need to setup a gradle Android build.
  21. Select **Install Android Build Template...** from the **Project** menu:
  22. .. image:: img/android_gradle_build.webp
  23. This will create a folder called **android** inside of your project that contains all the runtime files needed on Android. You can now customize this installation. Godot won't show this in the editor but you can find it with a file browser.
  24. You can read more about gradle builds here: :ref:`doc_android_gradle_build`.
  25. Installing the vendors plugin
  26. -----------------------------
  27. The vendors plugin can be downloaded from the asset library, search for "OpenXR vendors"
  28. and install the one named "Godot OpenXR Vendors plugin v4".
  29. .. image:: img/openxr_loader_asset_lib.webp
  30. You will find the installed files inside the **addons** folder. Alternatively you
  31. can manually install the vendors plugin by downloading it `from the release page here <https://github.com/GodotVR/godot_openxr_vendors/releases>`__.
  32. You will need to copy the `assets/addons/godotopenxrvendors` folder from the zip
  33. file into your projects `addons` folder.
  34. You can find the main repository of the vendors plugin `here <https://github.com/GodotVR/godot_openxr_vendors>`__.
  35. .. note::
  36. From Godot 4.6 onwards, the vendor plugin is now an optional but recommended plugin.
  37. Godot can export directly to most Android-compatible devices.
  38. This can be useful for demonstration and tutorial projects where a single APK can be deployed to multiple devices.
  39. The vendor plugin unlocks vendor specific implementations and settings, and may be required to release on app stores.
  40. Creating the export presets
  41. ---------------------------
  42. You will need to setup a separate export preset for each device, as each device will need its own loader included.
  43. Open **Project** and select **Export..**.
  44. Click on **Add..** and select **Android**.
  45. Next change the name of the export preset for the device you're setting this up for, say **Meta Quest**.
  46. And enable **Use Gradle Build**.
  47. Next change the **XR Mode** to **OpenXR**.
  48. If you want to use one-click deploy (described below), ensure that **Runnable** is enabled.
  49. If you've installed the vendor plugin you will also find entries for the different headsets under **XR Features**.
  50. Select the entry for your headset, if you see one.
  51. Otherwise, enable the Khronos plugin.
  52. .. image:: img/android_meta_quest.webp
  53. Scroll to the bottom of the list and you'll find additional XR feature sections,
  54. currently only **Meta XR Features**, **Pico XR Features**, **Magicleap XR Features**
  55. and **Khronos XR Features** for HTC are available. You will need to select the
  56. appropriate settings if you wish to use these features.
  57. Running on your device from the Godot editor
  58. --------------------------------------------
  59. If you've setup your export settings as described above, and your headset is connected to your computer and correctly recognized, you can launch it directly from the Godot editor using :ref:`doc_one-click_deploy`:
  60. .. image:: img/android_one_click_deploy.webp
  61. For some devices on some platforms, you may need to perform some extra steps in order for your device to be recognized correctly, so be sure to check the developer documentation from your headset vendor.
  62. For example, with the Meta Quest 2, you need to enable developer mode on the headset, and if you're on Windows, you'll need to install special ADB drivers. See the `official Meta Quest developer documentation <https://developer.oculus.com/documentation/native/android/mobile-device-setup/>`_ for more details.
  63. If you're having any issues with one-click deploy, check the :ref:`Troubleshooting section <doc_one-click_deploy_troubleshooting>`.