Skip to content
Latchkey

GitHub Actions Workflow for Build an Android App

Build an Android APK in CI and upload it as an artifact.

This workflow sets up the JDK, builds with the Gradle wrapper, runs unit tests, and uploads the APK.

The workflow

.github/workflows/android.yml
name: Android
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with: { distribution: temurin, java-version: '17' }
      - uses: gradle/actions/setup-gradle@v4
      - run: ./gradlew testDebugUnitTest assembleDebug
      - uses: actions/upload-artifact@v4
        with:
          name: app-debug
          path: app/build/outputs/apk/debug/app-debug.apk

Notes

  • setup-gradle handles the Gradle cache.
  • Keep Android builds on Linux runners -- they are far cheaper than macOS.
  • Sign release builds with secrets if you publish to the Play Store.

Run it cheaper

Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →