-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Remove the restriction on supported types for Godot Android plugins #97500
Merged
akien-mga
merged 3 commits into
godotengine:master
from
m4gr3d:update_godot_plugin_to_use_javaclasswrapper
Oct 1, 2024
Merged
Remove the restriction on supported types for Godot Android plugins #97500
akien-mga
merged 3 commits into
godotengine:master
from
m4gr3d:update_godot_plugin_to_use_javaclasswrapper
Oct 1, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2e1dc18
to
2e46cf9
Compare
c4376dd
to
f1f7e73
Compare
cc @reduz @akien-mga This PR may drastically simplify access to Android SDKs for Godot developers! |
akien-mga
approved these changes
Sep 28, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
AThousandShips
approved these changes
Sep 29, 2024
The Android plugin implementation is updated to use `JavaClassWrapper` which was fixed in godotengine#96182, thus removing the limitation on supported types. Note that `JavaClassWrapper` has also been updated in order to only provide access to public methods and constructor to GDScript.
Thanks for the fix of `JavaClassWrapper` in godotengine#96182 and the changes in the previous commit, this introduces an `AndroidRuntime` plugin which provides GDScript access to the Android runtime capabilities. This allows developers to get access to various Android capabilities without the need of a plugin. For example, the following logic can be used to check whether the device supports vibration: ``` var android_runtime = Engine.get_singleton("AndroidRuntime") if android_runtime: print("Checking if the device supports vibration") var vibrator_service = android_runtime.getApplicationContext().getSystemService("vibrator") if vibrator_service: if vibrator_service.hasVibrator(): print("Vibration is supported on device!") else: printerr("Vibration is not supported on device") else: printerr("Unable to retrieve the vibrator service") else: printerr("Couldn't find AndroidRuntime singleton") ```
…e `res://addons` directory
739ed91
to
4587d14
Compare
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The first commit updates the Android plugin implementation to use
JavaClassWrapper
which was fixed in #96182, thus removing the limitation on supported types.The second commit builds on that change to expose the Android runtime to developers by introducing a bundled
AndroidRuntime
plugin.For example, the following logic can be used to check whether the device supports vibration:
Those changes put together have significant impact for Godot developers on Android platforms as it removes the need for complex plugins in order to access Android libraries and SDKs.
So long as the library or SDK is written in Java or Kotlin, it only needs to be included in the build process via
EditorExportPlugin#_get_android_libraries (...)
orEditorExportPlugin#_get_android_dependencies(...)
to be directly accessible to the script logic!