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.apkNotes
setup-gradlehandles 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
GitHub Actions Workflow for Cache Gradle BuildsA GitHub Actions workflow for a Gradle project that caches the Gradle dependency and build cache so builds ru…
Flutter "Gradle task assembleDebug failed" in CIFix Flutter "Gradle task assembleDebug failed with exit code 1" in CI - a wrapped Android/Gradle build error.…