Skip to content

Android Build

Android development uses Gradle as the build system. This recipe demonstrates how to build Android apps including dependency resolution, testing, and APK generation.

name: Android Build
platform: android
environment:
android_sdk: 34
triggers:
- push
- pull_request
steps:
- name: Install dependencies
run: ./gradlew dependencies
- name: Run tests
run: ./gradlew test
- name: Build APK
run: ./gradlew assembleRelease
artifacts:
- app/build/outputs/**/*.apk

For Google Play Store distribution:

name: Android AAB Build
platform: android
environment:
android_sdk: 34
triggers:
- push
steps:
- name: Build bundle
run: ./gradlew bundleRelease
artifacts:
- app/build/outputs/**/*.aab

The typical Android build workflow includes:

  1. Dependency Resolution: ./gradlew dependencies downloads and caches all Gradle dependencies
  2. Unit Testing: ./gradlew test runs your test suite
  3. APK Build: ./gradlew assembleRelease creates a release APK
  4. AAB Build: ./gradlew bundleRelease creates an Android App Bundle for Play Store
  • Gradle Wrapper: The ./gradlew script is committed to your repo and handles version management
  • APK vs AAB: APK files are for direct installation; AAB (App Bundle) is required for Google Play Store
  • Release vs Debug: Add -Debug suffix (e.g., assembleDebug) for debug builds, or -Release for production
  • Build Signing: Release builds require signing configuration in build.gradle
artifacts:
- app/build/outputs/**/*.apk
- app/build/outputs/**/*.aab
- app/build/outputs/**/mapping.txt
name: Android Signed Build
platform: android
environment:
android_sdk: 34
variables:
ANDROID_KEYSTORE_BASE64: $ANDROID_KEYSTORE_BASE64
ANDROID_KEYSTORE_PASSWORD: $ANDROID_KEYSTORE_PASSWORD
ANDROID_KEY_ALIAS: $ANDROID_KEY_ALIAS
ANDROID_KEY_PASSWORD: $ANDROID_KEY_PASSWORD
triggers:
- push
steps:
- name: Setup signing keystore
run: |
echo $ANDROID_KEYSTORE_BASE64 | base64 -d > app/keystore.jks
- name: Build signed APK
run: ./gradlew assembleRelease
artifacts:
- app/build/outputs/**/*.apk