Distribute Android apps to testers using fastlane


This document describes how to distribute APK builds to testers using fastlane , an open source platform that automates building and releasing iOS and Android apps. This document follows instructions defined in a Fastfile . After you set up fastlane and your Fastfile , you can integrate App Distribution with your fastlane configuration.

Before you begin

If you haven't already, add Firebase to your Android project .

If you aren't using any other Firebase products, you only have to create a project and register your app. However, if you decide to use additional products in the future, be sure to complete all of the steps on the page linked above.

Step 1. Set up fastlane

  1. Install and set up fastlane .

  2. To add App Distribution to your fastlane configuration, run the following command from the root of your Android project:

    fastlane add_plugin firebase_app_distribution

    If the command prompts you with an option, select Option 3: RubyGems.org .

Step 2. Authenticate with Firebase

Before you can use the fastlane plugin, you must first authenticate with your Firebase project in one of the following ways. By default, the fastlane plugin looks for credentials from the Firebase CLI if no other authentication method is used.

Use Firebase service account credentials

Authenticating with a service account allows you to flexibly use the plugin with your continuous integration (CI) system. There are two ways to provide service account credentials:

  • Pass your service account key file to the firebase_app_distribution action. You might find this method convenient if you already have your service account key file in your build environment.
  • Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to your service account key file. You might prefer this method if you already have Application Default Credentials (ADC) configured for another Google service (e.g., Google Cloud ).
  1. On the Google Cloud console, select your project and create a new service account.
  2. Add the Firebase App Distribution Adminrole.
  3. Create a private json key and move the key to a location accessible to your build environment. Be sure to keep this file somewhere safe , as it grants administrator access to App Distribution in your Firebase project.
  4. Skip this step if you created your app after September 20, 2019: In the Google APIs console, enable the Firebase App Distribution API. When prompted, select the project with the same name as your Firebase project.
  5. Provide or locate your service account credentials:

    1. To pass your service account key to your lane's firebase_app_distribution action, set the service_credentials_file parameter with the path to your private key JSON file
    2. To locate your credentials with ADC, set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path for the private key JSON file. For example:

      export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/credentials/file.json

      For more information on authenticating with ADC, read Providing credentials to your application.