Automating your Firebase App Distribution flow — Android
Firebase App Distribution makes distributing your apps to trusted testers painless. By getting your apps onto testers’ devices quickly, you can get feedback early and often. Firebase app distribution is used by developers to publish their android/iOS apps to a particular set of users for User Acceptance Testing since unit testing the app is not always enough. You may ask how this is different from google play console’s internal app sharing, there’s a lot!
Advantages of Firebase App Distribution over others,
- No forms to be filled, no details needed to be added, build an apk/ipa and you are good to go.
- No review process to go through, upload the apk/ipa and it is released to the testers right away.
- No sdk required.
- Android and iOS builds are available in the same place, so its easy for the development team to manage all the builds.
- Combine Crashlytics with Firebase App Distribution to track the crashes and non fatal errors in the test build shared with your team members.
Steps to follow
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.
- Add dependencies
Add the following plugin and class path to your android project to add Firebase App Distribution functionalities.
2. Use Firebase service account credentials and authenticate the service account
To authenticate using service account credentials:
- On the Google Cloud Platform console, select your project and create a new service account.
- Add the Firebase App Distribution Admin role.
- 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.
3. Configure your distribution properties
In your app/build.gradle
file, configure App Distribution by adding at least one firebaseAppDistribution
section. You can configure App Distribution for both build types and product flavors. For example, to distribute the release
build to testers:
Possible App Distribution Build parameters are,
- serviceCredentialsFile — The path to your service account private key JSON file. Required only if you use service account authentication.
- appId — Your app’s Firebase App ID. Required only if you don’t have the Google Services Gradle plugin installed. You can find the App ID in the
google-services.json
file or in the Firebase console on the General Settings page. The value in yourbuild.gradle
file overrides the value output from thegoogle-services
plugin. - apkPath — Absolute or relative path to the APK file you want to upload. If unspecified, Gradle determines the file’s location using the APK output directory.
- releaseNotes or releaseNotesFile — Release notes for this build. You can either specify the release notes directly or the path to a plain text file.
- testers or testersFile — The email addresses of the testers you want to distribute builds to. You can specify the testers as a comma-separated list of email addresses:
testers="ali@example.com, bri@example.com, cal@example.com"
Or, you can specify the path to a file containing a comma-separated list of email addresses:
testersFile="/path/to/testers.txt"
4. Distribute to app testers using gradlew
Finally, to package your test app and invite testers, build the targets assembleBUILD-VARIANT
and appDistributionUploadBUILD-VARIANT
with your project's Gradle wrapper, where BUILD-VARIANT is the optional product flavor and build type you configured in the previous step.
For example, to distribute your app using the release
build variant, run the following command:
./gradlew assembleRelease appDistributionUploadRelease
Or, if you authenticated with your Google Account and didn’t provide credentials in your Gradle build file, include the FIREBASE_TOKEN
variable:
export FIREBASE_TOKEN=*token*
./gradlew --stop // Only needed for environment variable changes
./gradlew assembleRelease appDistributionUploadRelease
5. Distribute to app testers using Android Studio UI (my favourite)
Use your android studio to distribute the apk to firebase by navigating to the gradle option on top right → Tasks →other →appDistribution
Testers who haven’t been invited to test the app receive email invitations to get started (read the tester set up guide for instructions on how to install the app). Existing testers receive email notifications that a new build is ready to test.
Happy coding!!