Skip to content

feat: Android support with shared mobile templates #7

Description

@apotema

Summary

Add Android build and deployment support to labelle-cli, reusing shared infrastructure from iOS implementation.

Proposed Commands

labelle android build              # Build for Android device
labelle android build --emulator   # Build for Android emulator
labelle android run --emulator     # Build and run on emulator
labelle android studio             # Generate Android Studio project

Implementation Plan

Phase 1: Shared Mobile Infrastructure

Extract common code from iOS implementation into shared modules:

  • Shared mobile template (templates/mobile_main.zig)

    • Common sokol app callbacks (init, frame, event, cleanup)
    • Touch input handling (already platform-agnostic)
    • Scene loading from project's main module
    • Physics integration pattern
  • Shared build helpers (mobile/build_helpers.zig)

    • Common module imports (engine, main)
    • Sokol dependency configuration
    • Framework/library linking patterns
  • Shared deployment utilities (mobile/deploy.zig)

    • App bundle creation
    • Info/manifest generation
    • Binary packaging

Phase 2: Android-Specific Implementation

  • Android commands (android/android_commands.zig)

    • handleAndroidBuild() - Build APK/AAB
    • handleAndroidRun() - Deploy to emulator/device
    • handleAndroidStudio() - Generate Android Studio project
  • Android build.zig template

    • Target: aarch64-linux-android, x86_64-linux-android
    • NDK toolchain configuration
    • Sokol with OpenGL ES backend
  • Android manifest template (AndroidManifest.xml)

    • Activity configuration for NativeActivity
    • Permissions (if needed)
    • Screen orientation settings
  • Android Studio project generator

    • build.gradle templates
    • Project structure (app/, libs/)
    • Native library integration

Phase 3: Emulator/Device Deployment

  • ADB integration

    • Detect connected devices/emulators
    • Install APK (adb install)
    • Launch app (adb shell am start)
    • Boot emulator if needed (emulator -avd)
  • Hot reload support (stretch goal)

    • Watch for changes
    • Rebuild and reinstall

Shared vs Platform-Specific

Component iOS Android Shared
Sokol callbacks Yes
Touch handling Yes
Scene loading Yes
Physics script Yes
Build.zig template Partial
SDK paths iOS SDK NDK No
Deployment simctl adb No
Project gen Xcode Android Studio No

Dependencies

  • Android NDK (for cross-compilation)
  • ADB (for deployment)
  • Android Studio (optional, for signing/release)

Related

  • iOS support: Implemented in v0.3.7
  • Sokol supports Android via OpenGL ES backend

Acceptance Criteria

  • labelle android build produces working APK
  • labelle android run --emulator deploys and launches on emulator
  • Shared template works for both iOS and Android
  • Bouncing ball demo runs on Android emulator

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidAndroid platform support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions