deploying_to_android.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 11
  9. - Installing Android Studio
  10. - Creating a debug.keystore
  11. - Configuring the location of the Android SDK and debug.keystore in Godot
  12. See :ref:`doc_exporting_for_android` for the full details, and return here when you've finished these steps.
  13. Gradle Android build
  14. --------------------
  15. .. note::
  16. 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.
  17. 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.
  18. In order to include the vendor-specific OpenXR loader into your project, you will need to setup a gradle Android build.
  19. Select **Install Android Build Template...** from the **Project** menu:
  20. .. image:: img/android_gradle_build.webp
  21. 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.
  22. You can read more about gradle builds here: :ref:`doc_android_gradle_build`.
  23. Installing the loader plugin
  24. ----------------------------
  25. .. warning::
  26. The Android plugin structure has been restructured in Godot 4.2, if you've previously installed the loader plugin you need to delete it from the `android/plugins` folder.
  27. The loader plugin available in the asset library is still the old one, it will be updated to the new one after 4.2 is released.
  28. The loaders can be downloaded from the asset library, search for OpenXR Loaders and install the plugin:
  29. .. image:: img/openxr_loader_asset_lib.webp
  30. You will find the installed files inside the **addons** folder.
  31. Alternatively you can manually install the loader plugin by downloading the v2.x version of the plugin `from the release page here <https://github.com/GodotVR/godot_openxr_loaders/releases>`__.
  32. You will need to copy the `assets/addons/godotopenxr` folder from the zip file into your projects `assets/addons` folder.
  33. You can find the main repository of the loader plugin `here <https://github.com/GodotVR/godot_openxr_loaders>`__.
  34. Enabling the loader plugin
  35. --------------------------
  36. The loader plugin needs to be enabled before the export settings become accessible.
  37. Open **Project** and select **Project Settings...**.
  38. Go to the **Plugins** tab.
  39. Enable the **GodotOpenXR** plugin.
  40. .. image:: img/xr_enable_loader_plugin.webp
  41. Creating the export presets
  42. ---------------------------
  43. You will need to setup a separate export preset for each device, as each device will need its own loader included.
  44. Open **Project** and select **Export..**.
  45. Click on **Add..** and select **Android**.
  46. Next change the name of the export preset for the device you're setting this up for, say **Meta Quest**.
  47. And enable **Use Gradle Build**.
  48. If you want to use one-click deploy (described below), ensure that **Runnable** is enabled.
  49. If the loader plugins were installed correctly you should find entries for the different headsets, select the entry for meta:
  50. .. image:: img/android_meta_quest.webp
  51. Also change the **XR Mode** to **OpenXR**.
  52. Scroll to the bottom of the list and you'll find additional XR feature sections, currently only **Meta XR Features** is available.
  53. The hand tracking and passthrough settings here currently only work for the Meta Quest and you will need to select the appropriate settings if you wish to use these features.
  54. .. image:: img/xr_export_features.webp
  55. Now you can repeat the same process for the other devices.
  56. .. note::
  57. There are separate loaders for the Meta Quest, Pico and Lynx R1 headsets.
  58. The fourth option is the official Khronos (KHR) loader, in due time all headsets should work with this loader.
  59. At the moment this loader has been tested with the Magic Leap 2 and standalone HTC headsets.
  60. .. warning::
  61. While the Mobile Vulkan renderer has many optimizations targeted at mobile devices, we're still working out the kinks.
  62. It is highly advisable to use the OpenGL renderer for the time being when targeting Android based XR devices.
  63. Note that we are awaiting driver updates on various devices before Vulkan support will work on these.
  64. Running on your device from the Godot editor
  65. --------------------------------------------
  66. 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`:
  67. .. image:: img/android_one_click_deploy.webp
  68. 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.
  69. 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.
  70. If you're having any issues with one-click deploy, check the :ref:`Troubleshooting section <doc_one-click_deploy_troubleshooting>`.