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

Conversation

m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Sep 6, 2023

Draft for updates to the Android documentation for Godot 4.2:

Remaining TODOs (to be addressed in follow-up PRs):

  • Incorporate the NDK location or rather the instructions to compile godot-cpp via scons for Android when the NDK is not at the root directory. See Update the Android documentation for Godot 4.2 #7884 (comment)
  • Update the OpenXR documentation to provide information on how to build an Android plugin with OpenXR GDExtension capabilities

Docs maintainers note: ping Yuri once merged

Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

This is looking great to me! Just a couple notes from skimming the diff

tutorials/platform/android/android_in_app_purchases.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch from c451d57 to 5888d98 Compare September 7, 2023 14:40
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
tutorials/platform/android/android_plugin.rst Outdated Show resolved Hide resolved
@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch from 5888d98 to 17b5c59 Compare September 7, 2023 14:53
@paddy-exe
Copy link
Contributor

Reminder from RocketChat to incorporate the NDK location or rather the instructions to compile godot-cpp via scons for Android when the NDK is not at the root directory. In this case the ANDROID_NDK_ROOT path has to be set. Mine was at C:\Users\Patrick\AppData\Local\Android\Sdk\ndk\23.2.8568313

@tokengamedev
Copy link

I peeked into the documentation in the commit code. I am not sure I can read the documentation without this getting merged, but I tried. I have few comments, correct me if I am wrong somewhere,

Building and Packaging the Plugin

  1. We are dropping the local godot library aar file dependency in favor of maven dependency. I think it is better compared to V1, but can you confirm? Also, can you provide a beta version somewhere when engine beta version is released, as 4.2.0 stable is not available yet.

On a side note, version 4.1.1 version is missing in the maven repo

  1. When we package the plugin, the output will be a plugin directory as follows (non-gdextension)
+ MyPLugin
|
+--.bin/  # output location for the AAR binaries
|   |
|   +--MyPlugin.1.1.2.release.aar  # the release version of the aar file (naming standards is up to the creator)
|   |
|   +--MyPlugin.1.1.2.debug.aar  # the debug version of the aar file (naming standards is up to the creator)
|
+--.export/  # scripts directory
|   |
|   +--editor_export_plugin.gd  # EditorExportPlugin tool script
|   |
|   +--editor_plugin.gd # EditorPlugin tool script
|
+--plugin.cfg  # plugin INI file

Too much work for the plugin to be created, compared to just generating a gdap file, but I hope there are merits to it.

  1. Can you provide simple examples or usage for all methods inside editor_export_plugin (like _get_android_dependencies_maven_repos and others)

Using the plugin

  1. It seems like the plugin has to be enabled two times to be usable, one in project settings and one in export preset. Is that so?
  2. When the plugin is imported, which name will be used to fetch the plugin Singleton in code
    Name in the plugin.cfg or
    _get_name() function of the editor_export_plugin.gd

Thanks for the hard work of refactoring the plugin for android, I haven't started testing yet, let me know if there is any way I can get hold of godot library aar file so that I can start testing with simple plugins.

👍 😎

@Rindbee
Copy link

Rindbee commented Sep 15, 2023

I think it is necessary to modify cmdline-tools;latest (It is now cmdline-tools;11.0 and does not support JDK11) to cmdline-tools;10.0 for JDK11. See #7902 (comment).

@tokengamedev
Copy link

Is this going to be updated sometime soon?
Anyway I am busy next couple of weeks working for the critical part of my next game.

BTW, I saw aar files in the Godot builds, I hope I can use them for dependency. Let me know.

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Sep 25, 2023

Is this going to be updated sometime soon? Anyway I am busy next couple of weeks working for the critical part of my next game.

@tokengamedev yes, I'm working on incorporating the received feedback; expect an update this week.

BTW, I saw aar files in the Godot builds, I hope I can use them for dependency. Let me know.

The AAR files are generated for each build and also pushed to mavencentral so feel free to use whichever is easier for your workflow:

@mhilbrunner
Copy link
Member

@m4gr3d With Godot 4.2 beta imminent, what is the status of this? :)

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Oct 6, 2023

@m4gr3d With Godot 4.2 beta imminent, what is the status of this? :)

@mhilbrunner, working on that today!

I was blocked working on the sample apps to go alongside the documentation; I completed those yesterday (see godotengine/godot#82893 and m4gr3d/Godot-Android-Samples@94a6480) so I should be now unblocked.

@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch 3 times, most recently from 3a5d55a to 9779fa1 Compare October 6, 2023 20:05
@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch from 9779fa1 to d5a8803 Compare October 8, 2023 20:38
@mhilbrunner
Copy link
Member

Great to hear :) No pressure or anything, just wanted to check. Feel free to ping me once ready to review/merge!

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Oct 9, 2023

@tokengamedev I've addressed your questions / feedback below.

I peeked into the documentation in the commit code. I am not sure I can read the documentation without this getting merged, but I tried. I have few comments, correct me if I am wrong somewhere,

You can take a look as my branch as github should generate and make the documentation readable: https://github.com/m4gr3d/godot-docs/blob/update_android_plugin_tutorial/tutorials/platform/android/android_plugin.rst

Building and Packaging the Plugin

  1. We are dropping the local godot library aar file dependency in favor of maven dependency. I think it is better compared to V1, but can you confirm? Also, can you provide a beta version somewhere when engine beta version is released, as 4.2.0 stable is not available yet.

That's correct, maven dependency is the preferred and recommended approach, but the local godot library aar will continue to be provided for the time being for those that prefer that approach.

Until 4.2 is stable, you can use the snapshot versions available at https://s01.oss.sonatype.org/content/repositories/snapshots/org/godotengine/godot/4.2.0.dev-SNAPSHOT/. Those versions are updated for each dev / beta release.

To use the snapshot versions, you'll need to include the maven url for the snapshot repo. See here for reference.

On a side note, version 4.1.1 version is missing in the maven repo

This has been fixed, and it should now be available.

  1. When we package the plugin, the output will be a plugin directory as follows (non-gdextension)
+ MyPLugin
|
+--.bin/  # output location for the AAR binaries
|   |
|   +--MyPlugin.1.1.2.release.aar  # the release version of the aar file (naming standards is up to the creator)
|   |
|   +--MyPlugin.1.1.2.debug.aar  # the debug version of the aar file (naming standards is up to the creator)
|
+--.export/  # scripts directory
|   |
|   +--editor_export_plugin.gd  # EditorExportPlugin tool script
|   |
|   +--editor_plugin.gd # EditorPlugin tool script
|
+--plugin.cfg  # plugin INI file

Too much work for the plugin to be created, compared to just generating a gdap file, but I hope there are merits to it.

This has been reduced to the following:

    export_scripts_template/
    |
    +--export_plugin.gd         # export plugin tool script
    |
    +--plugin.cfg               # plugin INI file

So using your example, that would correspond to:

    MyPlugin/
    |
    +--MyPlugin.1.1.2.release.aar  # the release version of the aar file (naming standards is up to the creator)
    |
    +--MyPlugin.1.1.2.debug.aar  # the debug version of the aar file (naming standards is up to the creator)
    |
    +--export_plugin.gd         # export plugin tool script
    |
    +--plugin.cfg               # plugin INI file

So compared to the previous (.gdap) approach, only one additional script file is added.

but I hope there are merits to it.

The merits are most evident for plugins that provide customization options. The previous (.gdap) approach had no such capabilities. With the new approach, v2 Android plugins can now:

The Godot OpenXR Loaders plugin makes heavy use of the new capabilities to provide options, capabilities and plugin binaries for multiple OpenXR vendors. Take a look at its implementation for reference.

  1. Can you provide simple examples or usage for all methods inside editor_export_plugin (like _get_android_dependencies_maven_repos and others)

The Godot OpenXR Loaders plugin is a good reference for usage of the methods:

Using the plugin

  1. It seems like the plugin has to be enabled two times to be usable, one in project settings and one in export preset. Is that so?

No, only the first time in the project settings is required. Once the plugin is enabled in the project settings, it's then up to the plugin developer whether additional checks are required or not.
For example, the Godot OpenXR Loaders plugin supports multiple OpenXR vendors, so I include additional options in the export preset to let the user select which vendors should be enabled. The plugin also includes warnings to prevent users from enabling more than 1 vendor for a single export preset.

  1. When the plugin is imported, which name will be used to fetch the plugin Singleton in code
    Name in the plugin.cfg or
    _get_name() function of the editor_export_plugin.gd

The name used is the one returned by GodotPlugin#getPluginName().
I'd recommend the value in plugin.cfg and _get_name() function to also match that value (the provided github template do so), but it's not required.

Thanks for the hard work of refactoring the plugin for android, I haven't started testing yet, let me know if there is any way I can get hold of godot library aar file so that I can start testing with simple plugins.

👍 😎

Feel free to take a look at https://github.com/m4gr3d/Godot-Android-Samples/tree/master, a collection of samples I develop for reference.

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Oct 9, 2023

Great to hear :) No pressure or anything, just wanted to check. Feel free to ping me once ready to review/merge!

@mhilbrunner Ready for review!

@m4gr3d m4gr3d requested a review from mhilbrunner October 9, 2023 18:02
@@ -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

Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

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

The PNGs need to be converted to WebP for newly added/changed images (see image creation guidelines).

Besides that and the other small things I noted above, I spotted nothing. Great work :)

@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch from d14ccc8 to b3958d0 Compare October 10, 2023 16:22
@m4gr3d m4gr3d force-pushed the update_android_plugin_tutorial branch from b3958d0 to 66ee5cb Compare October 10, 2023 16:32
@m4gr3d
Copy link
Contributor Author

m4gr3d commented Oct 10, 2023

@mhilbrunner I've addressed your feedback!

@mhilbrunner mhilbrunner merged commit e269ed9 into godotengine:master Oct 10, 2023
1 check passed
@mhilbrunner
Copy link
Member

Merged 🎉 Great work!

@tokengamedev
Copy link

@m4gr3d thanks for the update, sorry could not reply earlier as been busy with the game code 🤓. I will try to check out this week.
Appreciate your great work ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation for exporting game as embeddable iOS/Android views
8 participants