Distribute app bundle releases to testers - Codelab

image10.png

In this codelab, you'll learn how to distribute Android App Bundle releases to testers using Firebase App Distribution and its Gradle plugin. App Distribution provides a central hub for you to manage pre-release versions of your app and the testers you invite to each release.

What you'll learn

  • How to connect your Firebase project to your Google Play account
  • How to link an app between Firebase and Google Play
  • How to package and build your app as an app bundle
  • How to create a release and share it with live testers
  • How to download and test new releases as a tester

What you'll need

  • Android Studio v4.0+
  • A signed bundle file that you generated from Android Studio
  • A Google Play account for which you're the Admin or Owner
  • An app in your Google Play Developer account that's been published to an internal, closed, production, or open-testing track
  • An email address you can use as a tester to receive new build invitations from Firebase
  1. Sign in to Firebase.
  2. In the Firebase console, click Add Project, then name your project "AppBundlesCodelab." Remember the Project ID for your Firebase project. If you don't edit the Project ID, Firebase automatically assigns a unique ID for your project.

image8.png

  1. When prompted, enable Google Analytics.
  2. Complete the remaining steps, then click Create project.

Add your app bundle to the project

  1. In the Firebase console, click Add app.

image5.png

  1. When registering your app, make sure to use the same package name as the app that's uploaded to your Google Play Developer account. Finally, click Register app.
  2. Complete the remaining steps to add the google-services.json file and the Firebase SDK to your app.
  3. Click Continue to console.

Connect to Google Play and Google Analytics

  1. Navigate to your Project settings.

image2.png

  1. In the Integrations tab, click Connect on the Google Play integration.
  2. Finally, click App Distribution under the Release & Monitor section. Then, click Get Started.

Now that you've completed these steps, your Firebase app will be linked to your app in your Google Play account as long as the apps' package names match.

Add the App Distribution Gradle plugin

Now, you'll use Android Studio to add App Distribution and its Gradle plugin as buildscript dependencies to your app.

  1. In your project-level Gradle file (android/build.gradle), add the App Distribution Gradle plugin and Google's Maven repository.
    buildscript {
        repositories {
            // Check that you have Google's Maven repository (if not, add it).
            google()
            jcenter()
        }
        dependencies {
            // Add the App Distribution Gradle plugin
            classpath `com.google.firebase:firebase-appdistribution-gradle:2.1.2`
        }
    }
    
  2. In your app-level Gradle file (android/app/build.gradle), add the App Distribution plugin:
    apply plugin: `com.android.application`
    
    // ...
    
    // Apply the App Distribution Gradle plugin
    apply plugin: `com.google.firebase.appdistribution`
    
    // ...
    
  3. If you're behind a corporate proxy or Firewall, add the following Java system property that enables App Distribution to upload your distributions to Firebase:
    -Djavax.net.ssl.trustStore=/path/to/truststore -Djavax.net.ssl.trustStorePassword=password
    

Authenticate your Firebase project

Before you can use the Gradle plugin, you'll need to authenticate your Firebase project. For this codelab, you'll sign in to your Google account using the plugin's login action.

  1. Run the following command at the root of your Android project:
    ~/your-android-project$ ./gradlew appDistributionLogin
    
  2. When the command prints an authentication link, open it in a browser. When prompted, sign in to your Google Account and grant permission to access your Firebase project. The Gradle command prints a refresh token, which the App Distribution plugin uses to authenticate with Firebase.
  3. Set the environment variable FIREBASE_TOKEN to the token from the previous step:
    ~/your-android-project$ export FIREBASE_TOKEN=your_firebase_token
    

In this step, you'll add yourself as a tester for the build you'll distribute later. Once you distribute the build, testers get email notifications from Firebase inviting them to test the new build.

In your app/build.gradle, add a firebaseAppDistribution section and include the following parameters:

  • appID: Your app's Firebase App ID. You can find it in the General tab of your Project settings.
  • artifactType: Your app's file type (AAB).
  • testers: Your testers' email addresses. For this codelab, add your own email so you can test your build once it's distributed.

For example:

android {

   // ...

   buildTypes {
       release {
           firebaseAppDistribution {
               appId="yourAppId"
               artifactType="AAB"
               testers="your@exampleemail.com, cerseimartell.772371@email.com"
           }
       }
   }

// ...
}

As an option, you can also override the values set in your build.gradle by passing command line arguments in the form of -PappDistribution-property-name=property-value.

  1. Run the bundleVariant Gradle task to build your app bundles file:
    $ ./gradlew :base:bundleRelease
    
  2. Locate the bundle in your application's build directory (the default location is app/build/outputs/bundle/release).
  3. To distribute the release, build the targets bundleRelease and appDistributionUploadRelease with your project's Gradle wrapper. Include the Firebase token (the one you received in step 3: Add App Distribution to your app).
    export FIREBASE_TOKEN=your_firebase_token
    
    ./gradlew --stop // Only needed for environment variable changes
    
    ./gradlew bundleRelease appDistributionUploadRelease
    

Testers will now receive email invitations to download and test the build. As the developer, you can now monitor the build in the Releases tab of the App Distribution dashboard.

In this section, you'll get set up as a tester in order to download the release you distributed. As a tester, you'll need to authenticate your test device and enable internal app sharing in the Google Play Store app.

  1. On your test device, sign in to your tester email account and open the invitation from Firebase.

image6.png

  1. Sign in with your Google account and accept the invitation to test the distributed release. As an option, you can also download Firebase App Tester, which prevents downloaded releases from being added to your device's Downloads folder. It also displays additional information about releases, such as the download progress and release version.

image9.png

  1. Tap Download on the release to install it from the Play Store.
  2. When prompted, complete the remaining steps to enable internal app sharing (the instructions are displayed on your test device and only need to be completed once).

Once the download is complete, your release will automatically appear as a shortcut in your device's home screen.

You just used Firebase App Distribution to upload an app bundle and distribute a release to testers.

Next steps