Plugin to automate "Install Android Build Templates"

Hello,

This one may be a strange one for most who operate on a single workstation setup.
Due to a very specific infrastructure requirement, I end up having to pull down the Godot project from a repo at the start of every coding session.

To minimize bloat on the Git-repo, the addons folders are symlinks to read-only folders shared across multiple Godot projects (which works a treat).

However, due to the dynamic nature of the Android Build Templates folder, this is not possible. The current alternative is to always have to remember to “Install Android Build Templates” at the start of the coding session.

Is it feasible to automate this step in a minimalist way (assume that the downloaded zip file is available at a read-only path) such that when the project is first loaded, the build templates are installed automatically?

Any suggestions from the community (or existing code snippets that I should look at?)

Thanks!

1 Like

Using the command line you can use --install-android-build-template but you need to export the project too with --export-debug <preset> or --export-release <preset>

Another way, albeit quite hacky, is to get the Project menu from the editor, search the Install Android Build Template entry, and emit the id_pressed signal manually. You should probably make a plugin that does that if the android folder is not found.

Example as an EditorScript. You’ll need to modify it if your editor language isn’t English:

@tool
extends EditorScript


func _run() -> void:
	var main = EditorInterface.get_base_control()
	# Try to find the Project PopupMenu 
	var possible = main.find_children("Project", "PopupMenu", true, false)
	for menu: PopupMenu in possible:
		# try to find the Install Android Build Template entry
		for idx in menu.item_count:
			var text = menu.get_item_text(idx)
			if text.contains("Android Build Template"):
				var id = menu.get_item_id(idx)
				# Emit the id_pressed signal with the id
				menu.id_pressed.emit(id)
				return
1 Like