Initialize a project (init_project)
init_project is a one-time wizard that inspects your native projects and writes fastlane/config/environments.yml for you. Use it when you onboard a new app, or when you want to regenerate the configuration from scratch.
Before you begin
- Complete Install & verify dependencies.
- Make sure
android/app/build.gradle(orbuild.gradle.kts) and/or yourios/*.xcodeprojare present. - For iOS, mark the schemes as Shared in Xcode so they can be detected (Apple: build schemes).
Step 1: Start the wizard
~/my-app $ bundle exec fastlane init_project[10:12:03]: Starting Fastlane lane: init_project[10:12:03]: --- Project setup ---? App name [MyApp]:? App identifier / package [com.example.myapp]:? Organization [Default]: Example Inc.Defaults are detected from app.json, strings.xml, package.json, google-services.json and build.gradle.
Step 2: Choose environments and platforms
Default environments: development, staging, uat, production? Environments (comma separated) [development,staging,uat,production]: development,staging,uat,production? Default environment:❯ development? Enable Android? (y/n) y? Enable iOS? (y/n) nYou can use any names, for example qa,preprod,production. Names are lower-cased and become the keys under android.environments and ios.environments.
Step 3: Configure each Android environment
The wizard reads productFlavors and buildTypes from Gradle (Groovy and Kotlin DSL). See Configure build variants for what these are. For each environment it suggests the matching flavor:
? Android project dir [android]:Detected flavors: dev, staging, prod--- Android · staging ---? Flavor for staging:❯ staging? Build type for staging:❯ release? Default artifact for staging:❯ AAB? Distribute staging via Firebase App Distribution? (y/n) yFrom those answers it derives the Gradle task and the output path. These follow the naming rules described in Build your app from the command line:
| Flavor | Build type | Artifact | gradle_task | artifact.glob |
|---|---|---|---|---|
| (none) | release | APK | assembleRelease | android/app/build/outputs/apk/release/*.apk |
| (none) | release | AAB | bundleRelease | android/app/build/outputs/bundle/release/*.aab |
| staging | release | APK | assembleStagingRelease | android/app/build/outputs/apk/staging/release/*.apk |
| staging | release | AAB | bundleStagingRelease | android/app/build/outputs/bundle/stagingRelease/*.aab |
Step 4: Notifications and output
? Send Microsoft Teams notifications? (y/n) y? Send Slack notifications? (y/n) n[10:14:41]: Wrote /Users/you/my-app/fastlane/config/environments.yml[10:14:41]: Added 9 key(s) to .env.example: FIREBASE_ANDROID_DEVELOPMENT_APP_ID, FIREBASE_ANDROID_DEVELOPMENT_GROUPS, ...[10:14:41]: Next: fill .env, then run `fastlane android doctor` / `fastlane setup`.[10:14:41]: Fastlane completed successfully: init_projectThe generated file never contains secrets. App IDs and groups are written as ${FIREBASE_ANDROID_<ENV>_APP_ID} placeholders, which the loader resolves from .env or CI secrets at run time.
android: enabled: true project_dir: android use_flavors: true environments: staging: description: Staging Android distribution flavor: staging build_type: release gradle_task: bundleStagingRelease artifact: type: AAB glob: android/app/build/outputs/bundle/stagingRelease/*.aab firebase: enabled: true app_id: "${FIREBASE_ANDROID_STAGING_APP_ID}" groups: "${FIREBASE_ANDROID_STAGING_GROUPS}" testers: '' app_testing: enabled: false # AI tests need an APKenvironments.yml already exists, the wizard asks before replacing it and keeps a backup at environments.yml.bak. Hand-written comments are not carried over, so compare the two files before committing.init_project refuses to run in CI (CI=true), because it needs a person to answer.Step 5: Validate
- 1
- 2
Run doctor
Shellbundle exec fastlane android doctor environment:staging
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
- AppleCustomizing the build schemes for a projectdeveloper.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project
- YAMLYAML 1.2 specificationyaml.org/spec/1.2.2/