Distribute your apps on Android with Firebase App Distribution.
In this post, I’m going to explain the step by step process of setup Fastlane with Firebase App Distribution.
What is Fastlane?
Fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.
It has a plugin system that makes it easy to extend its functionality. There are plugins for all sorts of workflows, such as for publishing app on to the Google Play Store and even one for Firebase App Distribution.
Why Fastlane?
- Save hours every time you push a new release to the store or beta testing service.
- Integrates with all your existing tools and services (more than 400 integrations).
- 100% open source under the MIT license.
- Easy setup assistant to get started in a few minutes.
- Runs on your machine, it’s your app and your data.
- Integrates with all major CI systems.
- Supports iOS, Mac, and Android apps.
- Extend and customize fastlane to fit your needs, you’re not dependent on anyone.
- Never remember any commands any more, just fastlane.
- Deploy from any computer, including a CI server.
What is Firebase App Distribution?
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. And if you use Crashlytics in your apps, you’ll automatically get stability metrics for all your builds, so you know when you’re ready to ship.
Getting started
Step 1: Installing fastlane
If you want more details please check this link. We continue with HomeBrew.
- Homebrew (macOS)
This way, you don’t have to install Ruby separately, and instead homebrew installs the adequate Ruby version for fastlane. See this page for details.
brew install fastlane
Step 2: Setting up fastlane
Navigate your terminal to your project’s directory and run.
fastlane init
You’ll be asked to confirm that you’re ready to begin, and then for a few pieces of information. To get started quickly:
- Provide the package name for your application when asked (e.g. com.developersancho.rorty)
- Press enter when asked for the path to your json secret file
- Answer ’n’ when asked if you plan on uploading info to Google Play via fastlane (we can set this up later)
That’s it! fastlane will automatically generate a configuration for you based on the information provided.
You can see the newly created ./fastlane
directory, with the following files:
Appfile
— defines configuration information that is global to your appFastfile
— defines the "lanes" that drive the behaviour of fastlane
Step 3: Add the Firebase App Distribution plugin
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.
To add App Distribution to your fastlane configuration, run the following command in Terminal:
fastlane add_plugin firebase_app_distribution
Step 4: Add the Load Json plugin
Loads a local JSON file and parses it, run the following command in Terminal:
fastlane add_plugin load_json
Step 5: Setting up Firebase Service Credentials
- Firebase Service Credentials is required for Fastlane for authentication purposes. Take a look at this section for more information.
- Go to the Google Cloud Platform console → Select your project → Create a new service account.
- Add the ‘Firebase App Distribution Admin’ role, like so:
- 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.
- Keep this file in the root/fastlane directory of your project. (In this example, I’m keeping the name of this file as
firebase_login_credentials.json
)
Step 6: Set up Test Groups
- Create a new file
groups.txt
in the fastlane directory.
- This means your application will be distributed to the
rorty-android-test
groups (these groups are created or managed in the App Distribution dashboard within the Firebase console).
Step 6: Create Lane
You can declare various lanes in Fastfile
which can have different behaviours or simply we can call them tasks.
1) First we need to set the default platform.
default_platform(:android)end
2) Next we need to tell Fastlane on which platform it needs to drive the lane. Inside default_platform add the following code
platform :android doend
3) We need to set configs before run the lane.
before_all do
ENV["FIREBASE_LOGIN_CREDENTIALS"] = "fastlane/firebase_login_credentials.json"
ENV["FIREBASE_APP_ID"] = "1:11111111111111:android:2222222222222"
end
4) Give a name and description to lane. Define a lane called testGoogle
.
desc "Submit a new Google Test Build to Firebase App Distribution"
lane :testGoogle do |options|
5) Now final code should be looking something like this:
- app: Your app’s Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page.
- apk_path: Refers to our apk path that we want to distribute.
- service_credentials_file: The path to your Google service account json file. See above for how to authenticate using service account credentials.
- groups_file: The tester groups you want to invite (refer to Manage testers). Groups are specified using group aliases, which you can look up in the Firebase console.
- release_notes: Release notes for this build.
Step 7: Test and Run the lane
Run the following command in terminal : fastlane testGoogle
.
References
- https://firebase.google.com/docs/app-distribution/android/distribute-fastlane
- https://docs.fastlane.tools/getting-started/android/setup/
- https://github.com/KrauseFx/fastlane-plugin-load_json
- https://github.com/nuhkoca/kotlin-android-fastlane-firebase-app-distribution
Thanks 🚀
I hope it helps you. If it is useful to you, you can clap this article and follow me for such these articles.
Happy and healthy coding!
Que tengas un buen día, continuará 😊 🏄🚀