Configure Android environmentsAndroid
Last updated 2026-10-07
The android block of fastlane/config/environments.yml defines how each environment is built and where it is distributed. You can generate it with fastlane init_project or write it by hand.
fastlane/config/environments.yml
android: enabled: true project_dir: "android" use_flavors: false # true when build.gradle defines productFlavors build: clean_before_build: false # run `gradle clean` first gradle_options: "" # e.g. "--no-daemon --stacktrace" environments: development: gradle_task: "assembleRelease" # ★ source of truth – exact Gradle task artifact: type: "APK" # APK or AAB glob: "android/app/build/outputs/apk/release/*.apk" firebase: enabled: true app_id: "${FIREBASE_ANDROID_DEV_APP_ID}" # empty → read from google-services.json groups: "${FIREBASE_ANDROID_DEV_GROUPS}" # tester group aliases, comma-separated testers: "" # or tester e-mails, comma-separated app_testing: enabled: true # AI tests for this environment release_notes: { enabled: true, source: "git", commit_count: 10 } notifications: { teams: { enabled: true }, slack: { enabled: false } }Key reference
| Key | Required | Description |
|---|---|---|
gradle_task | Yes | Exact Gradle task to run. The framework never guesses this: it is the source of truth. |
artifact.type | Yes | APK or AAB. Passed to Firebase as android_artifact_type. |
artifact.glob | Yes | Glob, relative to the project root, that matches the file Gradle produces. |
flavor / build_type | No | Informational (shown by doctor/info), and used by the interactive setup. |
firebase.app_id | When enabled | Firebase App ID (1:123…:android:abc…). Detected from google-services.json when empty. |
firebase.groups / testers | One of them | Group aliases or e-mail addresses, comma-separated. |
app_testing.enabled | No | Runs the App Testing agent after upload (APK only). |
No-flavor project
If Gradle only exposes assembleDebug, assembleRelease and bundleRelease, keep use_flavors: false and set gradle_task: "assembleRelease".
Note: in that case development, staging and production can all ship the same Release APK, and only the Firebase destination or group differs. That is intentional. For truly isolated environments (separate app IDs and backends), add product flavors.
Flavor project
If android/app/build.gradle defines product flavors, Gradle creates one task per flavor and build type combination:
android/app/build.gradle
android { flavorDimensions "env" productFlavors { dev { dimension "env"; applicationIdSuffix ".dev" } staging { dimension "env"; applicationIdSuffix ".staging" } prod { dimension "env" } }}Set use_flavors: true and configure each environment with the matching task:
YAML
staging: flavor: "staging" build_type: "release" gradle_task: "assembleStagingRelease" artifact: type: "APK" glob: "android/app/build/outputs/apk/staging/release/*.apk"The explicit gradle_task always wins. To see every task your project actually has, ask Gradle:
my-app/android — zsh
~/my-app $ ./gradlew tasks --all | grep -E "^(assemble|bundle).*Release "assembleDevRelease - Assembles main output for variant devReleaseassembleProdRelease - Assembles main output for variant prodReleaseassembleStagingRelease - Assembles main output for variant stagingReleasebundleDevRelease - Assembles bundle for variant devReleasebundleProdRelease - Assembles bundle for variant prodReleasebundleStagingRelease - Assembles bundle for variant stagingReleaseCommon Gradle task / glob combinations
| Project type | gradle_task | artifact.glob |
|---|---|---|
| No flavors, APK | assembleRelease | android/app/build/outputs/apk/release/*.apk |
| No flavors, AAB | bundleRelease | android/app/build/outputs/bundle/release/*.aab |
| Flavor dev, APK | assembleDevRelease | android/app/build/outputs/apk/dev/release/*.apk |
| Flavor prod, AAB | bundleProdRelease | android/app/build/outputs/bundle/prodRelease/*.aab |
| Custom variant | e.g. assembleInternalQaRelease | matching output folder |
APK or AAB?
| APK | AAB | |
|---|---|---|
| Install directly from Firebase | Yes | Only if the Firebase project is linked to Google Play |
| App Testing agent (AI tests) | Yes | No |
| Google Play upload | Legacy only | Required format (About App Bundles) |
Tip:
doctor checks that the task really exists (gradlew tasks --all) before a long build starts.Next steps
Official documentation
- AndroidConfigure build variants (flavors and build types)developer.android.com/build/build-variants
- AndroidBuild your app from the command linedeveloper.android.com/build/building-cmdline
- AndroidAbout Android App Bundles (AAB)developer.android.com/guide/app-bundle
- fastlanegradle actiondocs.fastlane.tools/actions/gradle/
Was this helpful?