android_studio.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. .. _doc_configuring_an_ide_android_studio:
  2. Android Studio
  3. ==============
  4. `Android Studio <https://developer.android.com/studio>`_ is a free
  5. IDE for Android development made by `Google <https://about.google/>`_ and `JetBrains <https://www.jetbrains.com/>`_.
  6. It's based on `IntelliJ IDEA <https://www.jetbrains.com/idea/>`_ and has a
  7. feature-rich editor which supports Java and C/C++. It can be used to
  8. work on Godot's core engine as well as the Android platform codebase.
  9. Importing the project
  10. ---------------------
  11. - From the Android Studio's welcome window select **Open**.
  12. .. figure:: img/android_studio_setup_project_1.png
  13. :figclass: figure-w480
  14. :align: center
  15. Android Studio's welcome window.
  16. - Navigate to ``<Godot root directory>/platform/android/java`` and select the ``settings.gradle`` file.
  17. - Android Studio will import and index the project.
  18. Android Studio project layout
  19. -----------------------------
  20. The project is organized using `Android Studio's modules <https://developer.android.com/studio/projects#ApplicationModules>`_:
  21. - ``lib`` module:
  22. - Located under ``<Godot root directory>/platform/android/java/lib``, this is a **library module** that organizes
  23. the Godot java and native code and make it available as a reusable dependency / artifact.
  24. - The artifact generated by this module is made available for other Android modules / projects to use as a dependency, via `MavenCentral <https://repo1.maven.org/maven2/org/godotengine/godot/>`_.
  25. - ``editor`` module:
  26. - Located under ``<Godot root directory>/platform/android/java/editor``, this is an **application module** that holds
  27. the source code for the Android port of the Godot Editor.
  28. - This module has a dependency on the ``lib`` module.
  29. - ``app`` module:
  30. - Located under ``<Godot root directory>/platform/android/java/app``, this is an **application module** that holds
  31. the source code for the Android build templates.
  32. - This module has a dependency on the ``lib`` module.
  33. Building & debugging the editor module
  34. --------------------------------------
  35. - To build the ``editor`` module:
  36. - Select the `Run/Debug Configurations drop down <https://developer.android.com/studio/run/rundebugconfig#running>`_ and select ``editor``.
  37. .. figure:: img/android_studio_editor_configurations_drop_down.webp
  38. :figclass: figure-w480
  39. :align: center
  40. - Select **Run > Run 'editor'** from the top menu or `click the Run icon <https://developer.android.com/studio/run/rundebugconfig#running>`_.
  41. - To debug the ``editor`` module:
  42. - Open the **Build Variants** window using **View > Tools Windows > Build Variants** from the top menu.
  43. - In the **Build Variants** window, make sure that in the **Active Build Variant** column, the ``:editor`` entry is set to **dev**.
  44. .. figure:: img/android_studio_editor_build_variant.webp
  45. :figclass: figure-w480
  46. :align: center
  47. - Open the **Run/Debug Configurations** window by clicking on **Run > Edit Configurations...** on the top menu.
  48. - In the **Run/Debug Configurations** window, select the ``editor`` entry, and under **Debugger** make sure the **Debug Type** is set to ``Dual (Java + Native)``
  49. .. figure:: img/android_studio_editor_debug_type_setup.webp
  50. :figclass: figure-w480
  51. :align: center
  52. - Select **Run > Debug 'editor'** from the top menu or `click the Debug icon <https://developer.android.com/studio/run/rundebugconfig#running>`_.
  53. Building & debugging the app module
  54. -----------------------------------
  55. The ``app`` module requires the presence of a Godot project in its ``assets`` directory (``<Godot root directory>/platform/android/java/app/assets``) to run.
  56. This is usually handled by the Godot Editor during the export process.
  57. While developing in Android Studio, it's necessary to manually add a Godot project under that directory to replicate the export process.
  58. Once that's done, you can follow the instructions below to run/debug the ``app`` module:
  59. - To build the ``app`` module:
  60. - Select the `Run/Debug Configurations drop down <https://developer.android.com/studio/run/rundebugconfig#running>`_ and select ``app``.
  61. .. figure:: img/android_studio_app_configurations_drop_down.webp
  62. :figclass: figure-w480
  63. :align: center
  64. - Select **Run > Run 'app'** from the top menu or `click the Run icon <https://developer.android.com/studio/run/rundebugconfig#running>`_.
  65. - To debug the ``app`` module:
  66. - Open the **Build Variants** window using **View > Tools Windows > Build Variants** from the top menu.
  67. - In the **Build Variants** window, make sure that in the **Active Build Variant** column, the ``:app`` entry is set to **dev**.
  68. .. figure:: img/android_studio_app_build_variant.webp
  69. :figclass: figure-w480
  70. :align: center
  71. - Open the **Run/Debug Configurations** window by clicking on **Run > Edit Configurations...** on the top menu.
  72. - In the **Run/Debug Configurations** window, select the ``app`` entry, and under **Debugger** make sure the **Debug Type** is set to ``Dual (Java + Native)``
  73. .. figure:: img/android_studio_app_debug_type_setup.webp
  74. :figclass: figure-w480
  75. :align: center
  76. - Select **Run > Debug 'app'** from the top menu or `click the Debug icon <https://developer.android.com/studio/run/rundebugconfig#running>`_.
  77. If you run into any issues, ask for help in
  78. `Godot's Android dev channel <https://chat.godotengine.org/channel/android>`__.