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.
Android Gradle Build YAML
Section titled “Android Gradle Build YAML”name: Android Buildplatform: 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/**/*.apkAndroid App Bundle Build
Section titled “Android App Bundle Build”For Google Play Store distribution:
name: Android AAB Buildplatform: android
environment: android_sdk: 34
triggers: - push
steps: - name: Build bundle run: ./gradlew bundleRelease
artifacts: - app/build/outputs/**/*.aabBuild Workflow
Section titled “Build Workflow”The typical Android build workflow includes:
- Dependency Resolution:
./gradlew dependenciesdownloads and caches all Gradle dependencies - Unit Testing:
./gradlew testruns your test suite - APK Build:
./gradlew assembleReleasecreates a release APK - AAB Build:
./gradlew bundleReleasecreates an Android App Bundle for Play Store
Key Points
Section titled “Key Points”- Gradle Wrapper: The
./gradlewscript 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
-Debugsuffix (e.g.,assembleDebug) for debug builds, or-Releasefor production - Build Signing: Release builds require signing configuration in
build.gradle
Collect Build Outputs
Section titled “Collect Build Outputs”artifacts: - app/build/outputs/**/*.apk - app/build/outputs/**/*.aab - app/build/outputs/**/mapping.txtAndroid with Signing
Section titled “Android with Signing”name: Android Signed Buildplatform: 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