Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Android Studio

Android Studio <https://developer.android.com/studio> — это бесплатная IDE для разработки приложений под Android, разработанная компаниями Google <https://about.google/> и JetBrains <https://www.jetbrains.com/>. Она основана на IntelliJ IDEA <https://www.jetbrains.com/idea/> и имеет многофункциональный редактор, поддерживающий Java и C/C++. Её можно использовать как для работы с основным движком Godot, так и с кодовой базой платформы Android.

Импортирование проекта

  • В окне приветствия Android Studio выберите Open.

../../../_images/android_studio_setup_project_1.png

Приветственное окно Android Studio.

  • Перейдите в <корневой каталог Godot>/platform/android/java и выберите файл settings.gradle.

  • Android Studio импортирует и проиндексирует проект.

Макет проекта Android Studio

Проект организован с использованием модулей Android Studio:

  • lib module:

    • Located under <Godot root directory>/platform/android/java/lib, this is a library module that organizes the Godot java and native code and make it available as a reusable Android library.

    • The generated Godot Android library is made available for other Android modules / projects via MavenCentral, along with its documentation.

  • editor module:

    • Located under <Godot root directory>/platform/android/java/editor, this is an application module that holds the source code for the Android and XR ports of the Godot Editor.

    • This module has a dependency on the lib module.

  • app module:

    • Located under <Godot root directory>/platform/android/java/app, this is an application module that holds the source code for the Android build templates.

    • This module has a dependency on the lib module.

Сборка и отладка модуля редактора

  • Чтобы собрать модуль редактор:

    ../../../_images/android_studio_editor_configurations_drop_down.webp
  • Для отладки модуля editor:

    • Откройте окно Build Variants, выбрав View > Tools Windows > Build Variants в верхнем меню.

    • In the Build Variants window, make sure that in the Active Build Variant column, the :editor entry is set to one of the Debug variants.

    ../../../_images/android_studio_editor_build_variant.webp
    • Откройте окно Run/Debug Configurations, нажав Run > Edit Configurations... в верхнем меню.

    • В окне Run/Debug Configurations выберите запись editor и в разделе Debugger убедитесь, что для Debug Type установлено значение Dual (Java + Native)

    • Click the + sign under the Symbol Directories section, and add the platform/android/java/lib/libs/tools/debug directory.

    ../../../_images/android_studio_editor_debug_type_setup.webp

Сборка и отладка модуля приложения

The app module requires the presence of a Godot project in its assets directory (<Godot root directory>/platform/android/java/app/src/main/assets) to run. This is usually handled by the Godot Editor during the export process. While developing in Android Studio, it's necessary to manually add a Godot project under that directory to replicate the export process. Once that's done, you can follow the instructions below to run/debug the app module:

  • Чтобы собрать модуль app:

    ../../../_images/android_studio_app_configurations_drop_down.webp
  • Для отладки модуля app:

    • Откройте окно Build Variants, выбрав View > Tools Windows > Build Variants в верхнем меню.

    • In the Build Variants window, make sure that in the Active Build Variant column, the :app entry is set to one of the Debug variants.

    ../../../_images/android_studio_app_build_variant.webp
    • Откройте окно Run/Debug Configurations, нажав Run > Edit Configurations... в верхнем меню.

    • В окне Run/Debug Configurations выберите запись app и в разделе Debugger убедитесь, что для Debug Type установлено значение Dual (Java + Native)

    • Click the + sign under the Symbol Directories section, and add the platform/android/java/lib/libs/debug directory.

    ../../../_images/android_studio_app_debug_type_setup.webp

Если у вас возникнут какие-либо проблемы, обратитесь за помощью на канале разработчиков Android Godot.