Android Export, End to End

Module 7 ยท Lesson 1 ยท ~45 min ยท one-time setup + repeatable build

This is the lesson that takes you from "it runs on my laptop" to "I handed my phone to a friend and they played it." Once done, you have a reproducible one-command build. You'll invoke it 50+ times before ship โ€” the investment pays back within a week.

Prerequisites (macOS)

  1. Java 17 JDK โ€” brew install openjdk@17, then follow the post-install sudo ln -sfn note brew prints. Verify with java -version.
  2. Android Studio โ€” developer.android.com/studio. You don't use the IDE, you need its SDK manager. Install it, launch once, let it finish the first-run setup.
  3. Android SDK components โ€” in Android Studio โ†’ More Actions โ†’ SDK Manager, install:
    • Android SDK Platform-Tools (gives you adb)
    • Android SDK Build-Tools (latest)
    • Android SDK Command-line Tools (latest)
    • Android SDK Platform for the latest API (e.g. 34)
  4. Godot โ€” 4.x stable from godotengine.org. The standard download, not the .NET version.

Note the SDK path โ€” it's usually ~/Library/Android/sdk. You'll paste it into Godot.

Telling Godot where Android lives

Open Godot. Editor โ†’ Editor Settings โ†’ Export โ†’ Android. Fill in:

Gotcha Godot is picky about Java versions. Java 17 is currently the sweet spot. Java 21 sometimes works, Java 8 definitely doesn't, and you'll get cryptic Gradle errors if you use the wrong one. If the export fails, first check java -version against what Godot points at.

Generating a debug keystore

Android requires every APK to be signed. For testing on your own phone, a "debug" keystore is fine โ€” it's just a throwaway key. Create one:

cd ~/.godot
keytool -keyalg RSA -genkeypair -alias androiddebugkey \
  -keypass android -keystore debug.keystore \
  -storepass android -dname "CN=Android Debug,O=Android,C=US" \
  -validity 9999 -deststoretype pkcs12

Now point Godot at ~/.godot/debug.keystore in Editor Settings. You'll generate a release keystore later for the Play Store โ€” that one you guard with your life (if you lose it, you can never update your app).

Installing the export templates

Export templates are the pre-built platform binaries Godot bundles your game into. Editor โ†’ Manage Export Templates โ†’ Download and Install. ~700MB download, ~2GB on disk. Grab a coffee.

Once installed, templates live in ~/Library/Application Support/Godot/export_templates/4.x.stable/. If you upgrade Godot, re-download.

Your first Android export preset

Project โ†’ Export โ†’ Add โ†’ Android. A preset appears. The key fields:

Deploying over USB

Enable developer mode on your Android phone: Settings โ†’ About phone โ†’ tap Build Number 7 times. Then Settings โ†’ Developer Options โ†’ USB Debugging: on.

Plug phone in. First connection will prompt on the phone for authorization โ€” accept "always allow from this computer." Verify:

adb devices
# Should print:
# List of devices attached
# R58M12ABCDE     device

If it prints unauthorized, re-confirm on phone. If it prints nothing, your USB cable may be charge-only (not data) โ€” swap it.

Back in Godot, you should now see a little Android icon in the top-right next to Play. Click it. Godot builds โ†’ installs โ†’ launches the game on your phone.

Milestone First time you see your game running on your actual phone with your actual thumb โ€” hold onto that feeling. That's the feeling. Everything from here is just iterations on that.

Headless / CLI export

Once you have a preset, you don't need the editor UI. This is what you'll actually use 90% of the time:

# In the project root
godot --headless --export-debug "Android Debug" build/lexicon-duel-debug.apk

# Then install to connected device
adb install -r build/lexicon-duel-debug.apk

# Or one-shot:
adb install -r build/lexicon-duel-debug.apk && adb shell am start -n com.yourname.lexiconduel/com.godot.game.GodotApp

Wrap it in a shell script named deploy.sh and put it at the root of your project. That script is your best friend for the next three months.

Debugging on device

Godot supports remote debugging over USB. With the phone connected:

Without this, you're printing to the void. Turn it on.

Common errors

Do this now

  1. Install the prereqs. Walk through every step.
  2. Make the preset. Get one successful debug export.
  3. Deploy to your phone. Play one full duel with your thumb.
  4. Write deploy.sh. Commit it. You'll thank yourself.
  5. Note anything that felt bad on touch โ€” tiny buttons, hit targets, font size. List goes into the Module 7 polish notes.