1. Overview
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 link your Firebase app to 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
- Latest Android Studio version
- A signed bundle file that you generated from Android Studio
- A Google Play developer account for which you're the Owner or Admin
- Your app in Google Play is set up on the Google Play app dashboard, and it has the following status:
- The app is distributed to one of the Google Play tracks (Internal testing, Closed testing, Open testing, or Production).
- The app's review in Google Play is complete and the app is published. Your app is published if the App status column displays one of the following statuses: Internal testing (not Draft internal testing), Closed testing, Open testing, or Production.
- An email address you can use as a tester to receive new build invitations from Firebase
2. Create a Firebase project
- Sign in to Firebase.
- 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.
- (Optional) When prompted, enable Google Analytics.
- Complete the remaining steps, then click Create project.
Add your app bundle to the project
- In the Firebase console, click Add app.
- 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.
- Complete the remaining steps to add your app's Firebase configuration file (
google-services.json
) to your app. Note that for Android, App Distribution doesn't have a Firebase SDK to add to your app. - Click Continue to console.
Link to Google Play
- In the Firebase console, go to your Project settings.
- In the Integrations tab, click Link on the Google Play card.
- Follow the on-screen instructions to enable the App Distribution integration, then select your newly created Firebase app to link to Google Play.
Now that you've completed these steps, your Firebase app will be linked to your app in your Google Play developer account as long as the apps' package names match.
3. Add App Distribution to your project
Add the App Distribution Gradle plugin
Now, you'll use Android Studio to add App Distribution and its Gradle plugin to your app.
- In your project-level Gradle file (
android/build.gradle.kts
), add the App Distribution Gradle plugin to theplugins
block.plugins { //... // Add the App Distribution Gradle plugin id("com.google.firebase.appdistribution") version "4.0.0" apply false }
- In your project-level Settings Gradle file (
android/settings.gradle.kts
), add Google's Maven repository to thepluginManagement
block.pluginManagement { // Check that you have Google's Maven repository (if not, add it). repositories { google() mavenCentral() } }
- In your app-level Gradle file (
android/app/build.gradle.kts
), add the App Distribution plugin to theplugins
block.plugins { //... // Add the App Distribution plugin id("com.google.firebase.appdistribution") }
- 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 Firebase CLI.
Run the following command at the root of your Android project:
~/your-android-project$ firebase login
The reference documentation contains more details.
4. Configure your bundle properties in Android Studio
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.kts
, 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 {
getByName("release") {
firebaseAppDistribution {
appId = "yourAppId"
artifactType = "AAB"
testers = "[email protected], [email protected], [email protected]"
}
}
}
// ...
}
As an option, you can also override the values set in your build.gradle.kts
by passing command line arguments in the form of -PappDistribution-property-name=property-value
.
5. Build and distribute a release
- Run the
bundleVariant
Gradle task to build your app bundles file:$ ./gradlew :base:bundleRelease
- Locate the bundle in your application's build directory (the default location is
app/build/outputs/bundle/release
). - To distribute the release, build the targets
bundleRelease
andappDistributionUploadRelease
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.
6. Download and test your release
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.
- On your test device, sign in to your tester email account and open the invitation from Firebase.
- 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. - Tap Download on the release to install it from the Play Store.
- 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.
7. Congratulations!
You just used Firebase App Distribution to upload an app bundle and distribute a release to testers.
Next steps
- Head over to the App Distribution documentation to learn more about how to manage testers for your release.
- See Build and test your Android App Bundle for information about other tools you can use to deploy your app.