This repository serves as a quickstart template for building a Godot Android plugin for Godot 4.2+.
plugin/demo
plugin/build.gradle.kts
plugin/export_scripts_template
plugin/src/main/AndroidManifest.xml
plugin/src/main/java
Note: Android Studio is the recommended IDE for developing Godot Android plugins. You can install the latest version from https://developer.android.com/studio.
To use this template, log in to github and click the green "Use this template" button at the top of the repository page. This will let you create a copy of this repository with a clean git history.
After cloning your own copy to your local machine, configure the project as needed. Several
TODO
have been added to the project to help identify where changes are needed; here's an
overview of the minimum set of modifications needed:
settings.gradle.kts
and update the value for rootProject.name
plugin/build.gradle.kts
and update the value for pluginName
plugin/export_scripts_template/plugin.cfg
and update the value for name
plugin/export_scripts_template/export_plugin.gd
and update the value for _plugin_name
plugin/build.gradle.kts
and update the value for pluginPackageName
plugin/src/main/java
match the
updated package namepackage
at the top of GodotAndroidPlugin.kt
matches the updated package nameplugin/export_scripts_template/plugin.cfg
description
fieldauthor
fieldversion
field./gradlew assemble
plugin/demo/addons
You can use the included Godot demo project to test the built Android plugin
Project
-> Project Settings...
-> Plugins
, and ensure the plugin is enabledProject
-> Install Android Build Template...
plugin/demo/main.gd
and update the logic as needed to reference
your plugin and its methodsAdditional dependencies added to plugin/build.gradle.kts
should be added to the _get_android_dependencies
function in plugin/export_scripts_template/export_plugin.gd
.
To make it easier to access the exposed Java / Kotlin APIs in the Godot Editor, it's recommended to provide one (or multiple) gdscript wrapper class(es) for your plugin users to interface with.
For example:
class_name PluginInterface extends Object
## Interface used to access the functionality provided by this plugin
var _plugin_name = "GDExtensionAndroidPluginTemplate"
var _plugin_singleton
func _init():
if Engine.has_singleton(_plugin_name):
_plugin_singleton = Engine.get_singleton(_plugin_name)
else:
printerr("Initialization error: unable to access the java logic")
## Shows a 'Hello World' toast.
func helloWorld():
if _plugin_singleton:
_plugin_singleton.helloWorld()
else:
printerr("Initialization error")