Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Android documentation for Godot 4.2 #7884

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _tools/redirects/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@mhilbrunner mhilbrunner Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means redirects would break for 4.0 and 4.1. I think adding a new second redirect with this instead should work fine, hopefully. Not 100% sure, it's been some time since messing with the redirects.

Alternatively (and potentially simpler) we could rename the page in 4.0 and 4.1 too and then have this redirect everywhere in 4.x, if it applies to all versions?

Or leave it as is, even if not 100% great. The redirects are pretty brittle, unfortunately. We can still change the doc title, just not the URL/file name.

Copy link
Contributor Author

@m4gr3d m4gr3d Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively (and potentially simpler) we could rename the page in 4.0 and 4.1 too and then have this redirect everywhere in 4.x, if it applies to all versions?

This change would apply to all 4.x versions so I can provide another PR for this change against the 4.1 and 4.0 branch for backport.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhilbrunner I've backported the changes in #8217

/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
Expand Down
2 changes: 1 addition & 1 deletion about/docs_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ New pages since version 3.1
Project workflow
^^^^^^^^^^^^^^^^

- :ref:`doc_android_custom_build`
- :ref:`doc_android_gradle_build`

2D
^^
Expand Down
2 changes: 1 addition & 1 deletion classes/class_editorexportplatformandroid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`

- :doc:`Android plugins documentation index <../tutorials/platform/index>`

Expand Down
32 changes: 16 additions & 16 deletions contributing/development/compiling/compiling_for_android.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
-----------------------------
Expand All @@ -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
---------------------------
Expand All @@ -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
---------------
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.
Expand Down
Binary file removed tutorials/export/img/custom_build_enable.png
Binary file not shown.
Binary file removed tutorials/export/img/custom_build_gradle.png
Binary file not shown.
Binary file not shown.
Binary file added tutorials/export/img/gradle_build_enable.webp
Binary file not shown.
Binary file added tutorials/export/img/gradle_build_gradle.webp
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tutorials/export/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 12 additions & 41 deletions tutorials/platform/android/android_in_app_purchases.rst
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -233,8 +221,8 @@ PurchaseState values:

# Matches Purchase.PurchaseState in the Play Billing Library
enum PurchaseState {
UNSPECIFIED,
PURCHASED,
UNSPECIFIED,
PURCHASED,
PENDING,
}

Expand All @@ -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()``:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Loading