浏览代码

Merge pull request #8217 from m4gr3d/android_docs_cleanup_4_1

Clean up the Android documentation for Godot 4.1
Max Hilbrunner 1 年之前
父节点
当前提交
4728a5410c

+ 1 - 1
_tools/redirects/redirects.csv

@@ -130,7 +130,7 @@ source,destination
 /getting_started/workflow/best_practices/scene_organization.html,/tutorials/best_practices/scene_organization.html
 /getting_started/workflow/best_practices/scenes_versus_scripts.html,/tutorials/best_practices/scenes_versus_scripts.html
 /getting_started/workflow/best_practices/what_are_godot_classes.html,/tutorials/best_practices/what_are_godot_classes.html
-/getting_started/workflow/export/android_custom_build.html,/tutorials/export/android_custom_build.html
+/getting_started/workflow/export/android_custom_build.html,/tutorials/export/android_gradle_build.html
 /getting_started/workflow/export/changing_application_icon_for_windows.html,/tutorials/export/changing_application_icon_for_windows.html
 /getting_started/workflow/export/exporting_for_android.html,/tutorials/export/exporting_for_android.html
 /getting_started/workflow/export/exporting_for_dedicated_servers.html,/tutorials/export/exporting_for_dedicated_servers.html

+ 1 - 1
about/docs_changelog.rst

@@ -235,7 +235,7 @@ New pages since version 3.1
 Project workflow
 ^^^^^^^^^^^^^^^^
 
-- :ref:`doc_android_custom_build`
+- :ref:`doc_android_gradle_build`
 
 2D
 ^^

+ 1 - 1
classes/class_editorexportplatformandroid.rst

@@ -21,7 +21,7 @@ Tutorials
 
 - :doc:`Exporting for Android <../tutorials/export/exporting_for_android>`
 
-- :doc:`Custom builds for Android <../tutorials/export/android_custom_build>`
+- :doc:`Gradle builds for Android <../tutorials/export/android_gradle_build>`
 
 .. rst-class:: classref-reftable-group
 

+ 16 - 16
contributing/development/compiling/compiling_for_android.rst

@@ -94,8 +94,8 @@ root directory with the following arguments:
 
 ::
 
-    scons platform=android target=template_release arch=armv7
-    scons platform=android target=template_release arch=arm64v8
+    scons platform=android target=template_release arch=arm32
+    scons platform=android target=template_release arch=arm64
     cd platform/android/java
     # On Windows
     .\gradlew generateGodotTemplates
@@ -109,8 +109,8 @@ The resulting APK will be located at ``bin/android_release.apk``.
 
 ::
 
-    scons platform=android target=template_debug arch=armv7
-    scons platform=android target=template_debug arch=arm64v8
+    scons platform=android target=template_debug arch=arm32
+    scons platform=android target=template_debug arch=arm64
     cd platform/android/java
     # On Windows
     .\gradlew generateGodotTemplates
@@ -135,9 +135,9 @@ example, for the release template:
 
 ::
 
-    scons platform=android target=template_release arch=armv7
-    scons platform=android target=template_release arch=arm64v8
-    scons platform=android target=template_release arch=x86
+    scons platform=android target=template_release arch=arm32
+    scons platform=android target=template_release arch=arm64
+    scons platform=android target=template_release arch=x86_32
     scons platform=android target=template_release arch=x86_64
     cd platform/android/java
     # On Windows
@@ -160,9 +160,9 @@ You can use the following commands to remove the generated export templates:
 
     cd platform/android/java
     # On Windows
-    .\gradlew cleanGodotTemplates
+    .\gradlew clean
     # On Linux and macOS
-    ./gradlew cleanGodotTemplates
+    ./gradlew clean
 
 
 Using the export templates
@@ -213,9 +213,9 @@ root directory with the following arguments:
 
 ::
 
-   scons platform=android arch=armv7 production=yes target=editor
-   scons platform=android arch=arm64v8 production=yes target=editor
-   scons platform=android arch=x86 production=yes target=editor
+   scons platform=android arch=arm32 production=yes target=editor
+   scons platform=android arch=arm64 production=yes target=editor
+   scons platform=android arch=x86_32 production=yes target=editor
    scons platform=android arch=x86_64 production=yes target=editor
    cd platform/android/java
    # On Windows
@@ -224,7 +224,7 @@ root directory with the following arguments:
    ./gradlew generateGodotEditor
 
 
-The resulting APK will be located at ``bin/android_editor.apk``.
+The resulting APK will be located at ``bin/android_editor_builds/android_editor-release.apk``.
 
 Removing the Editor templates
 -----------------------------
@@ -235,9 +235,9 @@ You can use the following commands to remove the generated editor templates:
 
     cd platform/android/java
     # On Windows
-   .\gradlew cleanGodotEditor
+   .\gradlew clean
    # On Linux and macOS
-   ./gradlew cleanGodotEditor
+   ./gradlew clean
 
 Installing the Godot editor
 ---------------------------
@@ -247,7 +247,7 @@ Open up a Terminal/Command Prompt and run the following commands from the root d
 
 ::
 
-   adb install ./bin/android_editor.apk
+   adb install ./bin/android_editor_builds/android_editor-release.apk
 
 Troubleshooting
 ---------------

+ 14 - 15
tutorials/export/android_custom_build.rst → tutorials/export/android_gradle_build.rst

@@ -1,10 +1,10 @@
-.. _doc_android_custom_build:
+.. _doc_android_gradle_build:
 
-Custom builds for Android
+Gradle builds for Android
 =========================
 
-Godot provides the option to use custom build Android templates. Instead of
-using the already pre-built template that ships with Godot, an actual Android
+Godot provides the option to build using the gradle buildsystem. Instead of
+using the already pre-built template that ships with Godot, an Android
 Java project gets installed into your project folder. Godot will then build it
 and use it as an export template every time you export the project.
 
@@ -13,45 +13,44 @@ There are some reasons why you may want to do this:
 * Modify the project before it's built.
 * Add external SDKs that build with your project.
 
-Configuring the custom build is a fairly straightforward process. But first
+Configuring the gradle build is a fairly straightforward process. But first
 you need to follow the steps in :ref:`exporting for android<doc_exporting_for_android>`
 up to **Setting it up in Godot**. After doing that, follow the steps below.
 
-Set up the custom build environment
+Set up the gradle build environment
 -----------------------------------
 
-Go to the Project menu, and install the *Custom Build* template:
+Go to the Project menu, and install the *Gradle Build* template:
 
-.. image:: img/custom_build_install_template.png
+.. image:: img/gradle_build_install_template.webp
 
 Make sure export templates are downloaded. If not, this menu will help you
 download them.
 
 A Gradle-based Android project will be created under ``res://android/build``.
-Editing these files is not needed unless you want to :ref:`create
-your own add-ons<doc_android_plugin>`, or you really need to modify the project.
+Editing these files is not needed unless you really need to modify the project.
 
 
-Enabling the custom build and exporting
+Enabling the gradle build and exporting
 ---------------------------------------
 
 When setting up the Android project in the **Project > Export** dialog,
-**Custom Build** needs to be enabled:
+**Gradle Build** needs to be enabled:
 
-.. image:: img/custom_build_enable.png
+.. image:: img/gradle_build_enable.webp
 
 From now on, attempting to export the project or one-click deploy will call the
 `Gradle <https://gradle.org/>`__ build system to generate fresh templates (this
 window will appear every time):
 
-.. image:: img/custom_build_gradle.png
+.. image:: img/gradle_build_gradle.webp
 
 The templates built will be used automatically afterwards, so no further
 configuration is needed.
 
 .. note::
 
-    When using the custom Android build system, assets that are placed within a
+    When using the gradle Android build system, assets that are placed within a
     folder whose name begins with an underscore will not be included in the
     generated APK. This does not apply to assets whose *file* name begins with
     an underscore.

二进制
tutorials/export/img/custom_build_enable.png


二进制
tutorials/export/img/custom_build_gradle.png


二进制
tutorials/export/img/custom_build_install_template.png


二进制
tutorials/export/img/gradle_build_enable.webp


二进制
tutorials/export/img/gradle_build_gradle.webp


二进制
tutorials/export/img/gradle_build_install_template.webp


+ 1 - 1
tutorials/export/index.rst

@@ -16,7 +16,7 @@ Export
    exporting_for_uwp
    exporting_for_ios
    exporting_for_android
-   android_custom_build
+   android_gradle_build
    exporting_for_web
    exporting_for_dedicated_servers
    one-click_deploy

+ 12 - 41
tutorials/platform/android/android_in_app_purchases.rst

@@ -1,17 +1,9 @@
-:article_outdated: True
-
 .. _doc_android_in_app_purchases:
 
 Android in-app purchases
 ========================
 
-Godot offers a first-party ``GodotGooglePlayBilling`` Android plugin compatible with Godot 3.2.2 and higher.
-This plugin uses the `Google Play Billing library <https://developer.android.com/google/play/billing>`__
-instead of the now deprecated AIDL IAP implementation. For details of how to migrate from the older
-``GodotPaymentsV3``, see the migration guide: `Migrating from Godot 3.2.1 and lower (GodotPaymentsV3)`_.
-
-If you learn better by looking at an example, you can find the demo project
-`here <https://github.com/godotengine/godot-demo-projects/tree/master/mobile/android_iap>`__.
+Godot offers a first-party ``GodotGooglePlayBilling`` Android plugin compatible with Godot 4 which uses the `Google Play Billing library <https://developer.android.com/google/play/billing>`_.
 
 
 Usage
@@ -20,13 +12,9 @@ Usage
 Getting started
 ***************
 
-Make sure you have enabled and successfully set up :ref:`Android Custom Builds <doc_android_custom_build>`.
+Make sure you have enabled and successfully set up :ref:`Android Gradle Builds <doc_android_gradle_build>`.
 Follow the compiling instructions on the ``GodotGooglePlayBilling`` `github page <https://github.com/godotengine/godot-google-play-billing>`__.
 
-.. note::
-
-    If you use a custom build you possibly have to put your own `godot-lib.***.release.aar` file in the `./godot-google-play-billing/libs/` folder.
-
 Then put the files `./godot-google-play-billing/build/outputs/aar/GodotGooglePlayBilling.***.release.aar` and `./GodotGooglePlayBilling.gdap` into your project in the `res://android/plugins` folder.
 
 The plugin should now show up in the Android export settings, where you can enable it.
@@ -35,7 +23,7 @@ The plugin should now show up in the Android export settings, where you can enab
 Initialize the plugin
 *********************
 
-To use the ``GodotGooglePlayBilling`` API: 
+To use the ``GodotGooglePlayBilling`` API:
 
 1. Obtain a reference to the ``GodotGooglePlayBilling`` singleton
 2. Connect handlers for the plugin signals
@@ -70,7 +58,7 @@ Initialization example:
 
             payment.startConnection()
         else:
-            print("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and the GodotGooglePlayBilling plugin in your Android export settings! IAP will not work.")
+            print("Android IAP support is not enabled. Make sure you have enabled 'Gradle Build' and the GodotGooglePlayBilling plugin in your Android export settings! IAP will not work.")
 
 The API must be in a connected state prior to use. The ``connected`` signal is sent
 when the connection process succeeds. You can also use ``isReady()`` to determine if the plugin
@@ -123,7 +111,7 @@ Query user purchases
 To retrieve a user's purchases, call the ``queryPurchases()`` function passing
 a string with the type of SKU to query. The SKU type string should be
 ``"inapp"`` for normal in-app purchases or ``"subs"`` for subscriptions.
-The ``query_purchases_response`` signal is sent with the result. 
+The ``query_purchases_response`` signal is sent with the result.
 The signal has a single parameter: a :ref:`Dictionary <class_Dictionary>` with
 a status code and either an array of purchases or an error message.
 Only active subscriptions and non-consumed one-time purchases are
@@ -224,7 +212,7 @@ Purchase fields:
 Check purchase state
 ********************
 
-Check the ``purchase_state`` value of a purchase to determine if a 
+Check the ``purchase_state`` value of a purchase to determine if a
 purchase was completed or is still pending.
 
 PurchaseState values:
@@ -233,8 +221,8 @@ PurchaseState values:
 
     # Matches Purchase.PurchaseState in the Play Billing Library
     enum PurchaseState {
-        UNSPECIFIED, 
-        PURCHASED, 
+        UNSPECIFIED,
+        PURCHASED,
         PENDING,
     }
 
@@ -255,7 +243,7 @@ If your in-app item is not a one-time purchase but a consumable item (e.g. coins
 multiple times, you can consume an item by calling ``consumePurchase()`` passing
 the ``purchase_token`` value from the purchase dictionary.
 Calling ``consumePurchase()`` automatically acknowledges a purchase.
-Consuming a product allows the user to purchase it again, it will no longer appear 
+Consuming a product allows the user to purchase it again, it will no longer appear
 in subsequent ``queryPurchases()`` calls unless it is repurchased.
 
 Example use of ``consumePurchase()``:
@@ -347,11 +335,11 @@ The proration values are defined as:
 ::
 
     enum SubscriptionProrationMode {
-        # Replacement takes effect immediately, and the remaining time 
+        # Replacement takes effect immediately, and the remaining time
         # will be prorated and credited to the user.
         IMMEDIATE_WITH_TIME_PRORATION = 1,
-        # Replacement takes effect immediately, and the billing cycle remains the same. 
-        # The price for the remaining period will be charged. 
+        # Replacement takes effect immediately, and the billing cycle remains the same.
+        # The price for the remaining period will be charged.
         # This option is only available for subscription upgrade.
         IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
         # Replacement takes effect immediately, and the new price will be charged on
@@ -395,20 +383,3 @@ Example use of ``confirmPriceChange()``:
             print("price_change_accepted")
         elif response_id == BillingResponse.CANCELED:
             print("price_change_canceled")
-
-
-Migrating from Godot 3.2.1 and lower (GodotPaymentsV3)
-------------------------------------------------------
-
-The new ``GodotGooglePlayBilling`` API is not compatible with its predecessor ``GodotPaymentsV3``.
-
-Changes
-*******
-
-- You need to enable the Custom Build option in your Android export settings and install
-  the ``GodotGooglePlayBilling`` plugin manually (see below for details)
-- All purchases have to be acknowledged by your app. This is a
-  `requirement from Google <https://developer.android.com/google/play/billing/integrate#process>`__.
-  Purchases that are not acknowledged by your app will be refunded.
-- Support for subscriptions
-- Signals (no polling or callback objects)

+ 235 - 0
tutorials/platform/android/android_library.rst

@@ -0,0 +1,235 @@
+.. _doc_android_library:
+
+Godot Android Library
+=====================
+
+The Godot Engine for Android platforms is designed to be used as an `Android library <https://developer.android.com/studio/projects/android-library>`_.
+This architecture enables several key features on Android platforms:
+
+- Ability to integrate the Gradle build system within the Godot Editor, which provides the ability to leverage more components from the Android ecosystem such as libraries and tools
+
+- Ability to make the engine portable and embeddable:
+
+  - Key in enabling the port of the Godot Editor to Android and mobile XR devices
+  - Key in allowing the integration and reuse of Godot's capabilities within existing codebase
+
+Below we describe some of the use-cases and scenarios this architecture enables.
+
+Using the Godot Android library
+-------------------------------
+
+The Godot Android library is packaged as an AAR archive file and hosted on `MavenCentral <https://central.sonatype.com/artifact/org.godotengine/godot>`_ along with `its documentation <https://javadoc.io/doc/org.godotengine/godot/latest/index.html>`_.
+
+It provides access to Godot APIs and capabilities on Android platforms for the following non-exhaustive use-cases.
+
+Godot Android plugins
+---------------------
+
+Android plugins are powerful tools to extend the capabilities of the Godot Engine
+by tapping into the functionality provided by Android platforms and ecosystem.
+
+An Android plugin is an Android library with a dependency on the Godot Android library
+which the plugin uses to integrate into the engine's lifecycle and to access Godot APIs.
+
+For more information, see :ref:`Godot Android plugins <doc_android_plugin>`.
+
+Embedding Godot in existing Android projects
+--------------------------------------------
+
+The Godot Engine can be embedded within existing Android applications or libraries,
+allowing developers to leverage mature and battle-tested code and libraries better suited to a specific task.
+
+The hosting component is responsible for driving the engine lifecycle via Godot's Android APIs.
+These APIs can also be used to provide bidirectional communication between the host and the embedded
+Godot instance allowing for greater control over the desired experience.
+
+We showcase how this is done using a sample Android app that embeds the Godot Engine as an Android view,
+and uses it to render 3D GLTF models.
+
+The `GLTF Viewer <https://github.com/m4gr3d/Godot-Android-Samples/tree/master/apps/gltf_viewer>`_ sample app uses an `Android RecyclerView component <https://developer.android.com/develop/ui/views/layout/recyclerview>`_ to create
+a list of GLTF items, populated from `Kenney's Food Kit pack <https://kenney.nl/assets/food-kit>`_.
+When an item on the list is selected, the app's logic interacts with the embedded Godot Engine to render the selected GLTF item as a 3D model.
+
+.. image:: img/gltf_viewer_sample_app_screenshot.webp
+
+The sample app source code can be found `on GitHub <https://github.com/m4gr3d/Godot-Android-Samples/tree/master/apps/gltf_viewer>`_.
+Follow the instructions on `its README <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/README.md>`_ to build and install it.
+
+Below we break-down the steps used to create the GLTF Viewer app.
+
+.. warning::
+
+  Currently only a single instance of the Godot Engine is supported per process.
+  You can configure the process the Android Activity runs under using the `android:process attribute <https://developer.android.com/guide/topics/manifest/activity-element#proc>`_.
+
+.. warning::
+
+  Automatic resizing / orientation configuration events are not supported and may cause a crash.
+  You can disable those events:
+
+  - By locking to a specific orientation using the `android:screenOrientation attribute <https://developer.android.com/guide/topics/manifest/activity-element#screen>`_.
+  - By declaring that the Activity will handle these configuration events using the `android:configChanges attribute <https://developer.android.com/guide/topics/manifest/activity-element#config>`_.
+
+1. Create the Android app
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. note::
+
+  The Android sample app was created using `Android Studio <https://developer.android.com/studio>`_
+  and using `Gradle <https://developer.android.com/build>`_ as the build system.
+
+  The Android ecosystem provides multiple tools, IDEs, build systems for creating Android apps
+  so feel free to use what you're familiar with, and update the steps below accordingly (contributions to this documentation are welcomed as well!).
+
+
+- Set up an Android application project. It may be a brand new empty project, or an existing project
+- Add the `maven dependency for the Godot Android library <https://central.sonatype.com/artifact/org.godotengine/godot>`_
+
+  - If using ``gradle``, add the following to the ``dependency`` section of the app's gradle build file. Make sure to update ``<version>`` to the latest version of the Godot Android library:
+
+  .. code-block:: kotlin
+
+    implementation("org.godotengine:godot:<version>")
+
+- If using ``gradle``, include the following ``aaptOptions`` configuration under the ``android > defaultConfig`` section of the app's gradle build file. Doing so allows ``gradle`` to include Godot's hidden directories when building the app binary.
+
+  - If your build system does not support including hidden directories, you can `configure the Godot project to not use hidden directories <https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-property-application-config-use-hidden-project-data-directory>`_ by deselecting ``Project Settings... > Application > Config > Use Hidden Project Data Directory``.
+
+.. code-block:: groovy
+
+  android {
+
+    defaultConfig {
+        // The default ignore pattern for the 'assets' directory includes hidden files and
+        // directories which are used by Godot projects, so we override it with the following.
+        aaptOptions {
+            ignoreAssetsPattern "!.svn:!.git:!.gitignore:!.ds_store:!*.scc:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"
+        }
+      ...
+
+- Create / update the application's Activity that will be hosting the Godot Engine instance. For the sample app, this is `MainActivity <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt>`_
+
+  - The host Activity should implement the `GodotHost interface <https://github.com/godotengine/godot/blob/master/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java>`_
+  - The sample app uses `Fragments <https://developer.android.com/guide/fragments>`_ to organize its UI, so it uses `GodotFragment <https://github.com/godotengine/godot/blob/master/platform/android/java/lib/src/org/godotengine/godot/GodotFragment.java>`_, a fragment component provided by the Godot Android library to automatically host and manage the Godot Engine instance.
+
+  .. code-block:: kotlin
+
+    private var godotFragment: GodotFragment? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+
+        setContentView(R.layout.activity_main)
+
+        val currentGodotFragment = supportFragmentManager.findFragmentById(R.id.godot_fragment_container)
+        if (currentGodotFragment is GodotFragment) {
+            godotFragment = currentGodotFragment
+        } else {
+            godotFragment = GodotFragment()
+            supportFragmentManager.beginTransaction()
+                .replace(R.id.godot_fragment_container, godotFragment!!)
+                .commitNowAllowingStateLoss()
+        }
+
+        ...
+
+.. note::
+
+  The Godot Android library also provide `GodotActivity <https://github.com/godotengine/godot/blob/master/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt>`_, an Activity component that can be extended to automatically host and manage the Godot Engine instance.
+
+  Alternatively, applications can directly create a `Godot <https://github.com/godotengine/godot/blob/master/platform/android/java/lib/src/org/godotengine/godot/Godot.kt>`_ instance, host and manage it themselves.
+
+- Using `GodotHost#getHostPlugins(...) <https://github.com/m4gr3d/Godot-Android-Samples/blob/0e3440f357f8be5b4c63a4fe75766793199a99d0/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt#L55>`_, the sample app creates a `runtime GodotPlugin instance <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/AppPlugin.kt>`_ that's used to send :ref:`signals <doc_signals>` to the ``gdscript`` logic
+
+  - The runtime ``GodotPlugin`` can also be used by ``gdscript`` logic to access JVM methods. For more information, see :ref:`Godot Android plugins <doc_android_plugin>`.
+
+- Add any additional logic that will be used by your application
+
+  - For the sample app, this includes adding the `ItemsSelectionFragment fragment <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt>`_ (and related classes), a fragment used to build and show the list of GLTF items
+
+- Open the ``AndroidManifest.xml`` file, and configure the orientation if needed using the `android:screenOrientation attribute <https://developer.android.com/guide/topics/manifest/activity-element#screen>`_
+
+  - If needed, disable automatic resizing / orientation configuration changes using the `android:configChanges attribute <https://developer.android.com/guide/topics/manifest/activity-element#config>`_
+
+.. code-block:: xml
+
+  <activity android:name=".MainActivity"
+      android:screenOrientation="fullUser"
+      android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
+      android:exported="true">
+
+      ...
+  </activity>
+
+
+2. Create the Godot project
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. note::
+
+  On Android, Godot's project files are exported to the ``assets`` directory of the generated ``apk`` binary.
+
+  We leverage that architecture to bind our Android app and Godot project together by creating the Godot project in the Android app's ``assets`` directory.
+
+  Note that it's also possible to create the Godot project in a separate directory and export it as a `PCK or ZIP file <https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#pck-versus-zip-pack-file-formats>`_
+  to the Android app's ``assets`` directory.
+  Using this approach requires passing the ``--main-pack <pck_or_zip_filepath_relative_to_assets_dir>`` argument to the hosted Godot Engine instance using `GodotHost#getCommandLine() <https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java#L45>`_.
+
+  The instructions below and the sample app follow the first approach of creating the Godot project in the Android app's ``assets`` directory.
+
+
+- As mentioned in the **note** above, open the Godot Editor and create a Godot project directly (no subfolder) in the ``assets`` directory of the Android application project
+
+  - See the sample app's `Godot project <https://github.com/m4gr3d/Godot-Android-Samples/tree/master/apps/gltf_viewer/src/main/assets>`_ for reference
+
+- Configure the Godot project as desired
+
+  - Make sure the `orientation <https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-property-display-window-handheld-orientation>`_ set for the Godot project matches the one set in the Android app's manifest
+  - For Android, make sure `textures/vram_compression/import_etc2_astc <https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-property-rendering-textures-vram-compression-import-etc2-astc>`_ is set to `true`
+
+- Update the Godot project script logic as needed
+
+  - For the sample app, the `script logic <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/src/main/assets/main.gd>`_ queries for the runtime ``GodotPlugin`` instance and uses it to register for signals fired by the app logic
+  - The app logic fires a signal every time an item is selected in the list. The signal contains the filepath of the GLTF model, which is used by the ``gdscript`` logic to render the model.
+
+  .. code-block:: gdscript
+
+    extends Node3D
+
+    # Reference to the gltf model that's currently being shown.
+    var current_gltf_node: Node3D = null
+
+    func _ready():
+      # Default asset to load when the app starts
+      _load_gltf("res://gltfs/food_kit/turkey.glb")
+
+      var appPlugin = Engine.get_singleton("AppPlugin")
+      if appPlugin:
+        print("App plugin is available")
+
+        # Signal fired from the app logic to update the gltf model being shown
+        appPlugin.connect("show_gltf", _load_gltf)
+      else:
+        print("App plugin is not available")
+
+
+    # Load the gltf model specified by the given path
+    func _load_gltf(gltf_path: String):
+      if current_gltf_node != null:
+        remove_child(current_gltf_node)
+
+      current_gltf_node = load(gltf_path).instantiate()
+
+      add_child(current_gltf_node)
+
+
+3. Build and run the app
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Once you complete configuration of your Godot project, build and run the Android app.
+If set up correctly, the host Activity will initialize the embedded Godot Engine on startup.
+The Godot Engine will check the ``assets`` directory for project files to load (unless configured to look for a ``main pack``), and will proceed to run the project.
+
+While the app is running on device, you can check `Android logcat <https://developer.android.com/studio/debug/logcat>`_ to investigate any errors or crashes.
+
+For reference, check the `build and install instructions <https://github.com/m4gr3d/Godot-Android-Samples/blob/master/apps/gltf_viewer/README.md>`_ for the GLTF Viewer sample app.

+ 2 - 17
tutorials/platform/android/android_plugin.rst

@@ -38,12 +38,12 @@ While introduced in Godot 3.2, the Android plugin system got a significant archi
 The new plugin system is backward-incompatible with the previous one and in Godot 4.0, the previous system was fully deprecated and removed.
 Since we previously did not version the Android plugin systems, the new one is now labelled ``v1`` and is the starting point for the modern Godot Android ecosystem.
 
-As a prerequisite, make sure you understand how to set up a :ref:`custom build environment<doc_android_custom_build>` for Android.
+As a prerequisite, make sure you understand how to set up a :ref:`gradle build environment<doc_android_gradle_build>` for Android.
 
 At its core, a Godot Android plugin is a `Android archive library <https://developer.android.com/studio/projects/android-library#aar-contents>`_ (*aar* archive file)
 with the following caveats:
 
-- The library must have a dependency on the Godot engine library (``godot-lib.<version>.<status>.aar``). A stable version is made available for each Godot release on the `Godot download page <https://godotengine.org/download>`_.
+- The library must have a dependency on the :ref:`Godot Android library <doc_android_library>`. A stable version is made available for each Godot release on `MavenCentral <https://central.sonatype.com/artifact/org.godotengine/godot>`_ and on the `Godot download page <https://godotengine.org/download>`_.
 - The library must include a specifically configured ``<meta-data>`` tag in its manifest file.
 
 Building an Android plugin
@@ -136,25 +136,10 @@ From your script::
         print(singleton.myPluginFunction("World"))
 
 
-Bundling GDExtension resources
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-An Android plugin can define and provide C/C++ GDExtension resources, either to provide and/or access functionality from the game logic.
-The GDExtension resources can be bundled within the plugin ``aar`` file which simplifies the distribution and deployment process:
-
-- The shared libraries (``.so``) for the defined GDExtension libraries will be automatically bundled by the ``aar`` build system.
-- Godot ``*.gdnlib`` and ``*.gdns`` resource files must be manually defined in the plugin ``assets`` directory.
-  The recommended path for these resources relative to the ``assets`` directory should be: ``godot/plugin/v1/[PluginName]/``.
-
-For GDExtension libraries, the plugin singleton object must override the ``org.godotengine.godot.plugin.GodotPlugin::getPluginGDNativeLibrariesPaths()`` method,
-and return the paths to the bundled GDExtension libraries config files (``*.gdextension``). The paths must be relative to the ``assets`` directory.
-At runtime, the plugin will provide these paths to Godot core which will use them to load and initialize the bundled GDExtension libraries.
-
 Reference implementations
 ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 - `Godot Oculus Mobile plugin <https://github.com/GodotVR/godot_oculus_mobile>`_
-  - `Bundled gdnative resources <https://github.com/GodotVR/godot_oculus_mobile/tree/master/plugin/src/main/assets/addons/godot_ovrmobile>`_
 - `Godot Google Play Billing plugin <https://github.com/godotengine/godot-google-play-billing>`_
 
 

二进制
tutorials/platform/android/img/gltf_viewer_sample_app_screenshot.webp


+ 4 - 5
tutorials/platform/android/index.rst

@@ -1,11 +1,10 @@
-:article_outdated: True
-
-Android plugins
-===============
+Android
+=======
 
 .. toctree::
    :maxdepth: 1
-   :name: toc-tutorials-plugins-android
+   :name: toc-tutorials-android
 
+   android_library
    android_plugin
    android_in_app_purchases

+ 4 - 4
tutorials/xr/deploying_to_android.rst

@@ -16,22 +16,22 @@ Before following the OpenXR-specific instructions here, you'll need to first set
 
 See :ref:`doc_exporting_for_android` for the full details, and return here when you've finished these steps.
 
-Custom Android build
+Gradle Android build
 --------------------
 
 .. note::
     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.
     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.
 
-In order to include the vendor-specific OpenXR loader into your project, you will need to setup a custom Android build.
+In order to include the vendor-specific OpenXR loader into your project, you will need to setup a gradle Android build.
 
 Select **Install Android Build Template...** from the **Project** menu:
 
-.. image:: img/android_custom_build.webp
+.. image:: img/android_gradle_build.webp
 
 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.
 
-You can read more about custom builds here: :ref:`doc_android_custom_build`.
+You can read more about gradle builds here: :ref:`doc_android_gradle_build`.
 
 Installing the loader plugins
 -----------------------------

+ 0 - 0
tutorials/xr/img/android_custom_build.webp → tutorials/xr/img/android_gradle_build.webp