Android Build Automation Setup: CI/CD, Signing, and Caching Guide
We often see developers complaining about slow builds in CI: a project with 15+ modules, Gradle running single-threaded, cold build 4–7 minutes, incremental 90 seconds. In a team of 10 people, that turns into a queue of builds blocking reviews. Our experience shows that proper build automation is not a silver bullet, but systematic work with Gradle configs, CI pipeline, and caching. We set everything up so that the build runs stably on any machine without manual steps.
Main Pain Points in Android Build Automation
How to sign APK/AAB safely in CI?
The most common problem. Developers store keystore in the repository (bad) or pass via command-line arguments in plain text (worse). The correct scheme: encode keystore in Base64, put it in a CI environment variable, decode to a temporary file before build, and delete after build. In build.gradle.kts, configure via environment variables:
android {
signingConfigs {
create("release") {
storeFile = file(System.getenv("KEYSTORE_PATH") ?: "debug.keystore")
storePassword = System.getenv("KEYSTORE_PASSWORD") ?: "android"
keyAlias = System.getenv("KEY_ALIAS") ?: "androiddebugkey"
keyPassword = System.getenv("KEY_PASSWORD") ?: "android"
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
}
Branch-based build configuration
Second pain point. main → release AAB for Play Store, develop → debug APK with test endpoints, release/* → staging APK for QA. Implement via a combination of buildFlavors + conditions in CI script. No need to create separate build.gradle files—one configuration with flavorDimensions is enough.
Why is Gradle caching important?
Without cache, CI downloads 200–400 MB of dependencies on every run. With proper caching of ~/.gradle/caches and ~/.gradle/wrapper, the first build after a build.gradle change takes full time; subsequent builds are incremental. On average, we save ~60% of build time after the first build. We use remote build cache (via S3) for distributed teams.
How We Set It Up
Base stack: Gradle 8.x + AGP 8.x + GitHub Actions / GitLab CI / Bitrise. We use Fastlane for tasks Gradle cannot handle out of the box: uploading to Google Play via supply, sending notifications, managing tracks (internal → alpha → production).
Structure of a typical CI pipeline (GitHub Actions):
# .github/workflows/android-release.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- name: Decode Keystore
run: echo "$KEYSTORE_BASE64" | base64 -d > app/release.keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Build Release AAB
run: ./gradlew bundleRelease
env:
KEYSTORE_PATH: release.keystore
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: release-aab
path: app/build/outputs/bundle/release/app-release.aab
We also configure gradle.properties for CI: org.gradle.daemon=false (daemon is not needed in CI), org.gradle.parallel=true, org.gradle.configureondemand=true. On projects with multiple modules, this reduces configuration time by 30–40%.
Parallel Execution and Optimization
If the project is monolithic, parallelization gives almost no effect. But with a modular architecture (:core, :feature-auth, :feature-feed, :app), Gradle builds a dependency graph and compiles independent modules in parallel. ./gradlew assembleDebug --parallel on an 8-core agent yields a 2–3x speedup compared to sequential builds. This makes our optimized setup 2–3 times faster than a standard configuration.
For large teams, we integrate Gradle Build Cache—either via Gradle Enterprise (paid) or an open-source solution with an S3 backend.
| Build Type |
Without Optimization |
With Optimization (cache + parallel) |
| Cold (all modules) |
5–7 min |
2–3 min |
| Incremental |
90 sec |
20–30 sec |
The Gradle User Manual recommends combining both approaches.
CI Platform Comparison for Android
| CI Platform |
Setup Features |
Average Build Time After Cache |
| GitHub Actions |
Simple integration, large ecosystem |
~2 min |
| GitLab CI |
Built-in Docker, excellent cache |
~1.5 min |
| Bitrise |
Optimized for mobile, many ready steps |
~2.5 min |
Common missteps when configuring CI
- Incorrect keystore encoding (Base64 with line breaks) leads to decoding errors.
- Missing cache between runs: without using
actions/cache with a proper key, each build re-downloads dependencies.
- Using debug signing in a release AAB—Google Play will reject such file.
- Forgetting to disable Gradle Daemon in CI, causing instability.
What’s Included in Our Work
- Audit of the current
build.gradle (Groovy → Kotlin DSL, plugin versions, suboptimal configs)
- Signing config via CI environment variables
- CI pipeline for your platform (GitHub Actions, GitLab CI, Bitrise)
- Gradle caching (local and remote)
- Branch-based configuration using build flavors
- Comprehensive documentation for the team, including setup guides and troubleshooting
- Developer training session (up to 2 hours) to ensure smooth adoption
- Access to our example repositories and templates
- Post-delivery support for 2 weeks to address any issues
- Stability guarantee—everything works without manual adjustments after delivery
Our Process
- Initial consultation and analysis of the current build.
- Migration to modern Gradle + Kotlin DSL (if needed).
- Signing config via CI secrets.
- CI configuration with caching and parallelism.
- Testing on several branches (main, develop, release/).
- Documentation and handover to the team.
Cost is calculated individually after requirement analysis. Typical investment starts at $1,500 for a single-module project and ranges up to $3,500 for complex multi-module setups. Timeline: 2–3 days for a single-module project, up to 5 days for multi-module. Contact us for a project assessment—we’ll help implement build automation end-to-end. Request a consultation to get exact deadlines and pricing for your project.
We have over 5 years of experience in Android development and have set up pipelines for 30+ projects—from startups to enterprise apps. Our engineers stay up-to-date with the latest Gradle and AGP versions, so you get a modern configuration without outdated practices.
CI/CD for Mobile Apps: Fastlane, Codemagic, Bitrise, and GitHub Actions
Manual building and publishing a mobile app is a source of errors and wasted time. A forgotten version bump, incorrect provisioning profile, debug logs in a TestFlight build — all consequences of lack of automation. A typical team spends 3–4 hours per week on manual build operations. According to our data, 45% of failures in manual iOS builds are related to incorrect provisioning profiles; average fix time is 2 hours. Automation via Fastlane and Match eliminates this problem entirely.
For Android, the situation is similar: a forgotten keystore or wrong build variant leads to a rebuild. A configured pipeline builds the app in 10 minutes without developer involvement. Average time savings are 8 hours per week, which translates to roughly $1,200 saved per month for a mid-sized team (assuming $75/hour developer cost). As a result, the team focuses on features, not the release process. Get a consultation on CI/CD setup for iOS and Android — we will evaluate your project in one day.
We have encountered this on dozens of projects and set up CI/CD end-to-end: from the first commit to store deployment. Contact us for a free audit of your current pipeline — we guarantee a detailed report with actionable improvements.
What problems does CI/CD solve?
- Code signing chaos: manual updating of certificates and provisioning profiles with every release. Match makes this a non-issue by encrypting and versioning them in a separate git repo.
- Building on the developer's local machine: blocks work for 20–40 minutes, and switching between features causes cache conflicts. CI parallelizes builds across environments.
- Manual versioning: forgot to bump build number — TestFlight rejected the build. Rebuilding with the correct number takes another hour. Automation fixes this in seconds.
- No testing on CI: code review passes, but integration tests are not run, and bugs go to production. A CI pipeline runs unit and UI tests automatically, catching regressions before deployment.
How does Fastlane solve code signing?
Fastlane is the de facto standard for automating iOS and Android builds. Fastfile describes lanes — sequences of actions. Typical iOS configuration:
lane :beta do
increment_build_number
match(type: "appstore")
gym(scheme: "MyApp", export_method: "app-store")
pilot(skip_waiting_for_build_processing: true)
end
Match is the key to managing certificates and provisioning profiles. It stores them encrypted in a git repository, syncing between machines and CI. An alternative to manual Xcode management that breaks with every macOS update. Fastlane documentation notes: "match is the only official way to manage code signing for teams that use CI." Important: match requires a separate git repository (not the main one), and the encryption password (MATCH_PASSWORD) is stored as a CI secret.
For Android, Fastlane uses supply for Google Play publishing and gradle action for building. Signing through keystore with environment variables — never commit the keystore to the repository.
The main pain of Fastlane: Ruby environment. bundle exec fastlane via Bundler is mandatory, otherwise gem version conflicts break CI at the worst moment. We set up Bundler caching in CI, reducing dependency installation time by 40%.
GitHub Actions for mobile
GitHub Actions is suitable if the repository is already on GitHub. For iOS, you need a macOS runner — runs-on: macos-14 (Apple Silicon). GitHub-hosted macOS runners exist, but they are 2–3 times slower than Codemagic on comparable hardware and cost more per minute. Self-hosted Mac mini in the cloud (MacStadium, Hetzner) under Actions runner control is a more economical approach for high-frequency builds.
Typical workflow for iOS:
jobs:
build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec fastlane beta
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.ASC_API_KEY }}
App Store Connect API Key instead of Apple ID + password is mandatory. Apple ID with 2FA does not work reliably on CI. API Key is created in App Store Connect → Users and Access → Keys. We include creation and rotation of these keys in our work.
To set up GitHub Actions for iOS, follow these steps:
- Create a YAML file in
.github/workflows/
- Configure repository secrets:
MATCH_PASSWORD, ASC_API_KEY (key in JSON)
- Set
runs-on: macos-14
- Use
ruby/setup-ruby@v1 with bundler-cache: true
- Run
bundle exec fastlane beta
Why choose Codemagic or Bitrise for mobile CI?
Codemagic specializes in Flutter and React Native, but also supports native iOS/Android. Killer feature — codemagic.yaml configuration and macOS M2 machines without additional setup. Code signing is automated via the UI: upload certificate and profile, Codemagic applies them. Convenient for teams without DevOps. Builds on M2 run 2 times faster than on GitHub Actions Intel runners.
Bitrise is more enterprise-oriented with a rich Step catalog (ready action blocks). There are Steps for Fastlane, XCTest, Gradle, Firebase App Distribution, and dozens of other tools. The visual Workflow Editor lowers the entry barrier. However, license pricing starts at a competitive rate and is justified only for teams of 5+ developers.
| Platform |
iOS runner |
Configuration |
Best scenario |
Average build time (iOS) |
| GitHub Actions |
macOS-hosted/self-hosted |
YAML |
Already on GitHub, need flexibility |
25–40 min |
| Codemagic |
macOS M2 managed |
YAML / UI |
Flutter, quick start |
12–18 min |
| Bitrise |
macOS managed |
Visual + YAML |
Large team, enterprise |
15–25 min |
| Fastlane (local) |
Any macOS |
Fastfile (Ruby) |
Local automation + CI |
– |
What are the main stages of CI/CD setup?
| Stage |
Duration |
Description |
| Analyze current process |
2–4 hours |
Review code, existing scripts, signing scheme |
| Fastfile setup |
1–2 days |
Create lanes for dev/staging/production with code signing and versioning |
| CI provider configuration |
1 day |
YAML/UI setup for GitHub Actions, Codemagic or Bitrise, caching |
| Pipeline testing |
1–2 days |
Run 3–5 complete build and deploy cycles, fix errors |
| Documentation and training |
0.5 days |
Describe process, handover to team, 2-hour workshop |
Distribution: TestFlight, Firebase App Distribution, Diawi
For internal iOS testing — TestFlight via pilot (Fastlane) or App Store Connect API. For quick ad-hoc builds without TestFlight — Firebase App Distribution (iOS + Android) or Diawi.
Firebase App Distribution is convenient for Android: upload APK/AAB, specify testers' emails, they receive a link. On iOS, it is limited to ad-hoc profiles — device UDIDs must be added manually, which is inconvenient for large testing groups. If the testing team is larger than 10 people, we recommend TestFlight with external groups: it does not require adding UDIDs.
How to set up versioning without errors?
Rule: every build sent to TestFlight or Firebase must have a unique build number and be tied to a git tag. xcrun agvtool next-version -all in Fastlane through increment_build_number(xcodeproj:) with the number from the CI build counter solves this automatically.
Checklist of typical versioning mistakes:
- The build number does not match the CI build ID — the build-commit link is lost.
- Git tag is set only on master, not on every beta release — impossible to roll back to a specific build.
- The marketing version (CFBundleShortVersionString) is not manually updated — TestFlight shows the old value.
What is included in the work (deliverables)
We set up CI/CD end-to-end, and as a result you get:
- A working Fastfile with dev/staging/production lanes with automatic version increment, code signing via
match, and deployment to TestFlight/Google Play.
- Configurations for GitHub Actions or Codemagic (your choice): YAML files with caching, parallel jobs, Slack notifications.
- App Store Connect API Key and push notification setup (APNs/FCM).
- Documentation on running builds and updating certificates.
- Team training: 2-hour online workshop on using the pipeline.
- Post-release support for 14 days (fixing any potential errors).
Why trust us with setup?
We are a team of mobile developers with 5+ years of experience in CI/CD. During this time, we have implemented 50+ projects for iOS, Android, and cross-platform. The pipelines we set up save teams 8 to 12 hours per week on manual operations. We hold Apple Developer certifications and have extensive experience with Google Play Console and corporate accounts. The investment in setup pays off in 2–3 months. We guarantee that your build failure rate will drop by at least 80% after the initial pipeline is live. Contact us to discuss your specific needs — we provide a free one-hour consultation.
Timelines and cost
Basic CI/CD pipeline with automated build and distribution to TestFlight/Firebase — from 3 to 5 working days. Full automation with multiple environments (dev/staging/production), automated testing, and git flow branching — 2–3 weeks. Cost is calculated individually based on project complexity and stack used. Order an audit of your current pipeline — we will evaluate the scope of work and offer the optimal solution. Get a consultation — contact us.