London Market 43 · Prepare the Android export

Market Day London · Lesson 43 of 50 · Publishing · About 40 min

Nia's team wants to test a debug build on a phone before an adult publisher prepares a Google Play candidate.

Watercolour of Nia carrying a basket past the produce, bread and flower stalls at a London street market.
What you’ll make Prepare an Android package identifier, build number and file format for testing or release.

Download the projects from the course page. In Godot’s Project Manager, choose Import, select project.godot, and use Run Project (F5). Start from checkpoints/42 when the lesson builds on prior work, or copy the checkpoints/43 folder to try this lesson on its own. Read the file names in the steps before editing. Keep the checkpoint ZIP intact and make edits in an extracted working copy.

Identify. Set a project-specific package name. → Configure. Check templates and SDKs. → Test. Use an appropriate device build. → Review. Check the candidate with an adult.
Identify → Configure → Test → Review
Godot checkpoint window for Prepare the Android export
From the running Godot checkpoint.

Build it step by step

Language and tools in this lesson String.get_extension(), split(), comparisons, APK, AAB, version code.

  1. Separate two build formats

    An APK can be installed on a permitted Android test device. Google Play uses an Android App Bundle (AAB) for most new applications. Record whether each file is a device build or a store candidate.

    Why it works A filename describes a format. Release signing and the platform's checks are separate.

  2. Run the Android lab

    Import checkpoint 43, open main.gd and press F5. Run all three buttons to compare a test APK, an AAB and a previously used version code.

    Why it works The lab checks sample metadata. It never builds or validates an actual store package.

  3. Read an extension

    In inspect_build(), look up the final extension of the filename and normalise it to lowercase. Substitute market-dryrun.zip for one name and try the button again.

    var extension := filename.get_extension().to_lower()

    Why it works Case normalisation lets .AAB and .aab follow the same branch.

  4. Set up Godot with an adult

    In the full game project, go to Project > Export. Check matching export templates, the Java SDK and Android SDK paths against the official Godot guide. Inspect the supplied Android preset and replace its example package name in your own release copy.

    Why it works The SDK is the set of Android build tools. The package name connects updates to an existing listing.

  5. Choose build numbers and API level

    Open the Android preset's Version Name and Version Code settings. Choose your player-visible version name and a higher build code for a new upload. Check the current target API for mobile apps on the linked Play page and configure the toolchain and preset accordingly.

    Why it works The store compares integer version codes. API requirements follow the platform's schedule.

  6. Rehearse the two handovers

    With an adult, use a debug APK for a permitted device test when available. For a real Play release, they prepare the correct AAB, handle signing and follow eligibility and testing rules. Keep signing keys private.

    Why it works Choose build and testing routes based on the actual distribution task.

Watch the values change

  1. Inspect a test APK Code 8 is newer and the extension is apk.
    What you see. The lab routes it to a local test.
  2. Inspect an AAB Code 8 is newer and the extension is aab.
    What you see. The lab marks it as a candidate needing further checks.
  3. Reuse build code 7 The simulated listing already used 7.
    What you see. The lab asks for a higher number.

Predict before you run Does saving a file ending in .aab mean it has already passed Google Play checks?

Reveal the answer

It still needs an appropriate export, signing and review. Use the checklist to collect evidence for each stage.

Complete checkpoint

APK and AAB route to different checks. Code 7 needs a higher version code.

main.gd

extends Control

const Lab = preload("res://release_lab.gd")
const TITLE = "Prepare the Android export"
var ui: VBoxContainer

func _ready() -> void:
	ui = VBoxContainer.new()
	ui.set_script(Lab)
	add_child(ui)
	ui.start(TITLE)
	build()

const PREVIOUS_CODE := 7
const EXAMPLE_ID := "org.example.briarlane"

func build() -> void:
	ui.say("Inspect fictional Android packages. No build is signed or uploaded.")
	ui.option("Inspect a device APK", inspect_build.bind("market-debug.apk", 8, EXAMPLE_ID))
	ui.option("Inspect a candidate AAB", inspect_build.bind("market-release.AAB", 8, EXAMPLE_ID))
	ui.option("Inspect an older build", inspect_build.bind("market-release.aab", 7, EXAMPLE_ID))

func inspect_build(filename: String, code: int, package_id: String) -> void:
	var extension := filename.get_extension().to_lower()
	if package_id.contains(" ") or package_id.split(".").size() < 2:
		ui.say("Check the package identifier in the official export guide.")
	elif code <= PREVIOUS_CODE:
		ui.say("Use a version code greater than %d." % PREVIOUS_CODE)
	elif extension == "apk":
		ui.say("APK for permitted local installation. Record the device and results.")
	elif extension == "aab":
		ui.say("AAB candidate. Verify toolchain, signing, Play Console and current policy.")
	else:
		ui.say("Choose an APK or AAB for this exercise.")

release_lab.gd

extends VBoxContainer

var output: Label

func start(title_text: String) -> void:
	set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	offset_left = 32.0
	offset_top = 28.0
	offset_right = -32.0
	offset_bottom = -28.0
	add_theme_constant_override("separation", 12)
	var background := ColorRect.new()
	background.color = Color("#20342e")
	background.mouse_filter = Control.MOUSE_FILTER_IGNORE
	get_parent().add_child(background)
	background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	get_parent().move_child(background, 0)
	var title := Label.new()
	title.text = title_text
	title.add_theme_font_size_override("font_size", 32)
	title.add_theme_color_override("font_color", Color("#f3c991"))
	add_child(title)
	output = Label.new()
	output.custom_minimum_size.y = 151.0
	output.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
	output.add_theme_font_size_override("font_size", 19)
	add_child(output)

func say(message: String) -> void:
	output.text = message

func option(label: String, command: Callable) -> void:
	var button := Button.new()
	button.text = label
	button.custom_minimum_size.y = 46.0
	button.add_theme_font_size_override("font_size", 19)
	button.pressed.connect(command)
	add_child(button)

GDScript line by line

Follow the line numbers, including the indent at the start of each line. Find the code the game will run first, then look for the function that reacts when you tap or change something.

Read main.gd line by line
  1. extends ControlStarts with Godot's Control type. This script gets the abilities of that type and adds the game's own rules.
  2. const Lab = preload("res://release_lab.gd")Creates a constant named Lab. The expression prepares a resource at a fixed project path when the script is loaded.
  3. const TITLE = "Prepare the Android export"Creates a constant named TITLE. The expression uses the text inside the quotes.
  4. var ui: VBoxContainerDeclares ui for later use. A colon followed by a type says which kind of value belongs here.
  5. func _ready() -> void:Godot calls this once after the scene and its children are ready. Use it to set up the room and connect controls.
  6. ui = VBoxContainer.new()Stores the new value in ui. The expression creates a new VBoxContainer object.
  7. ui.set_script(Lab)Calls ui.set_script with the values in its parentheses.
  8. add_child(ui)Adds the new node to the scene tree so that Godot can run and draw it.
  9. ui.start(TITLE)Calls ui.start with the values in its parentheses.
  10. build()Calls build with the values in its parentheses.
  11. const PREVIOUS_CODE := 7Creates a constant named PREVIOUS_CODE. The expression uses the whole number 7. Godot infers the type from the first value.
  12. const EXAMPLE_ID := "org.example.briarlane"Creates a constant named EXAMPLE_ID. The expression uses the text inside the quotes. Godot infers the type from the first value.
  13. func build() -> void:Defines build, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  14. ui.say("Inspect fictional Android packages. No build is signed or uploaded.")Calls ui.say with the values in its parentheses.
  15. ui.option("Inspect a device APK", inspect_build.bind("market-debug.apk", 8, EXAMPLE_ID))Calls ui.option with the values in its parentheses.
  16. ui.option("Inspect a candidate AAB", inspect_build.bind("market-release.AAB", 8, EXAMPLE_ID))Calls ui.option with the values in its parentheses.
  17. ui.option("Inspect an older build", inspect_build.bind("market-release.aab", 7, EXAMPLE_ID))Calls ui.option with the values in its parentheses.
  18. func inspect_build(filename: String, code: int, package_id: String) -> void:Defines inspect build, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  19. var extension := filename.get_extension().to_lower()Creates a variable named extension. The expression calls filename.get_extension with the values in its parentheses. Godot infers the type from the first value.
  20. if package_id.contains(" ") or package_id.split(".").size() < 2:Checks package_id.contains(" ") or package_id.split(".").size() < 2. The indented instructions below run only if this test passes.
  21. ui.say("Check the package identifier in the official export guide.")Calls ui.say with the values in its parentheses.
  22. elif code <= PREVIOUS_CODE:If the earlier branches did not run, checks code <= PREVIOUS_CODE next.
  23. ui.say("Use a version code greater than %d." % PREVIOUS_CODE)Calls ui.say with the values in its parentheses.
  24. elif extension == "apk":If the earlier branches did not run, checks extension == "apk" next.
  25. ui.say("APK for permitted local installation. Record the device and results.")Calls ui.say with the values in its parentheses.
  26. elif extension == "aab":If the earlier branches did not run, checks extension == "aab" next.
  27. ui.say("AAB candidate. Verify toolchain, signing, Play Console and current policy.")Calls ui.say with the values in its parentheses.
  28. else:Runs the indented fallback instructions if none of the earlier tests passed.
  29. ui.say("Choose an APK or AAB for this exercise.")Calls ui.say with the values in its parentheses.
Read release_lab.gd line by line
  1. extends VBoxContainerStarts with Godot's VBoxContainer type. This script gets the abilities of that type and adds the game's own rules.
  2. var output: LabelDeclares output for later use. A colon followed by a type says which kind of value belongs here.
  3. func start(title_text: String) -> void:Defines start, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  4. set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)Positions this Control relative to the bounds of its parent.
  5. offset_left = 32.0Stores the new value in offset_left. The expression reads 32.0.
  6. offset_top = 28.0Stores the new value in offset_top. The expression reads 28.0.
  7. offset_right = -32.0Stores the new value in offset_right. The expression reads -32.0.
  8. offset_bottom = -28.0Stores the new value in offset_bottom. The expression reads -28.0.
  9. add_theme_constant_override("separation", 12)Calls add_theme_constant_override with the values in its parentheses.
  10. var background := ColorRect.new()Creates a variable named background. The expression creates a new ColorRect object. Godot infers the type from the first value.
  11. background.color = Color("#20342e")Stores the new value in background.color. The expression builds a colour from these values.
  12. background.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates background.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE.
  13. get_parent().add_child(background)Calls get_parent with the values in its parentheses.
  14. background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)Positions this Control relative to the bounds of its parent.
  15. get_parent().move_child(background, 0)Calls get_parent with the values in its parentheses.
  16. var title := Label.new()Creates a variable named title. The expression creates a new Label object. Godot infers the type from the first value.
  17. title.text = title_textUpdates title.text, which controls the words a player sees. The expression reads title_text.
  18. title.add_theme_font_size_override("font_size", 32)Calls title.add_theme_font_size_override with the values in its parentheses.
  19. title.add_theme_color_override("font_color", Color("#f3c991"))Calls title.add_theme_color_override with the values in its parentheses.
  20. add_child(title)Adds the new node to the scene tree so that Godot can run and draw it.
  21. output = Label.new()Stores the new value in output. The expression creates a new Label object.
  22. output.custom_minimum_size.y = 151.0Stores the new value in output.custom_minimum_size.y. The expression reads 151.0.
  23. output.autowrap_mode = TextServer.AUTOWRAP_WORD_SMARTStores the new value in output.autowrap_mode. The expression reads TextServer.AUTOWRAP_WORD_SMART.
  24. output.add_theme_font_size_override("font_size", 19)Calls output.add_theme_font_size_override with the values in its parentheses.
  25. add_child(output)Adds the new node to the scene tree so that Godot can run and draw it.
  26. func say(message: String) -> void:Defines say, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  27. output.text = messageUpdates output.text, which controls the words a player sees. The expression reads message.
  28. func option(label: String, command: Callable) -> void:Defines option, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  29. var button := Button.new()Creates a variable named button. The expression creates a new Button object. Godot infers the type from the first value.
  30. button.text = labelUpdates button.text, which controls the words a player sees. The expression reads label.
  31. button.custom_minimum_size.y = 46.0Stores the new value in button.custom_minimum_size.y. The expression reads 46.0.
  32. button.add_theme_font_size_override("font_size", 19)Calls button.add_theme_font_size_override with the values in its parentheses.
  33. button.pressed.connect(command)Links a signal to the function that should run when the event happens.
  34. add_child(button)Adds the new node to the scene tree so that Godot can run and draw it.

Find and fix a bug

If Godot cannot export, check the template version and the SDK paths in the official export guide before changing game code.

Try a change

Ages 10–12. Sort three example filenames. Ages 13–16. Create a dry-run table with package identifier, version name, build code and current target API.

Official instructions