Using Fastlane for Flutter: A complete guide - LogRocket Blog (2024)

Fastlane is an open source tool suite used to automate releases and deployments for Android and iOS apps, favored by many developers because it can significantly cut down on deployment time. Working with Android and iOS apps can be quite tedious, especially when handling screenshots, beta deployments, App Store deployments, and code signing, among others.

This article will serve as a guide on how to use Fastlane with your Flutter applications. Let’s get started!

  • Setting up
  • Initializing Fastlane
  • Deploying the application for testing

Prerequisites

To proceed, I recommend you have:

  • An active Flutter application
  • Familiarity with Flutter and Flutter SDK
  • Familiarity with Firebase and have Firebase CLI installed on their device
  • Installed Homebrew. If you haven’t, here is a link on how to do so on Mac

Setting up

Installing Fastlane

To make use of Fastlane in your Flutter application, you will need to install it correctly (note that we are using macOS to run our application).

You can check out the documentation on installing Fastlane on any device of your choice. Use the command below to install Fastlane:

brew install fastlane

To confirm Fastlane has been installed successfully on your device, check its version by running the following command:

fastlane -v

If the version of Fastlane and the path to where we installed it is returned, we have installed Fastlane successfully.

Setting up your package name

The package name of your application must be distinct.

If you created your Flutter application using Android Studio, you will already have a default package name assigned to your application. The package name is unique to your local device but may not be on Google Play or the App Store.

If you want to change your application package name, you can do so in Android Studio.At the project pane in Android Studio, click on the settings icon at the top:

Using Fastlane for Flutter: A complete guide - LogRocket Blog (1)

This will bring up a dropdown; ensure that the Compact Directories option is unchecked:

Using Fastlane for Flutter: A complete guide - LogRocket Blog (2)

Next, you can refactor your package name. To do this, right-click on your application’s package name and select Refactor, then Rename. A window will pop up; click Rename Package in the window, rename, and then save the update.

Setting up Supply and getting our JSON file

Supply is a tool in Fastlane that enables you to upload app metadata, binaries, and screenshots to Google Play.

To initialize Supply, you need to have successfully uploaded an APK to your app in the Google Play Console at least once. Setting it up requires downloading a credentials file from your Google Developers service account.

Now, we need to obtain our JSON secret file. This file will be required when we set up our Fastlane deployment flow. To get this file, follow these steps:

  1. Open your Google Play Console account, click on the Account Details section, and take note of the Developer Account ID listed
  2. Next, click on Setup, then on API access
  3. Click on the Create new service accountbutton
  4. Follow the Google Cloud Platform link in the dialog; this will open a new window, then do the following:
    1. Click on the Create a service accountbutton located at the top of the Google Cloud Platform Console
    2. Ensure that you are on the correct Google Cloud Platform project
    3. Input a service account name and click Create
    4. Next, select a role; find and select Service Account User, and click Continue
    5. Click Done
    6. Next, select the Actionsvertical three-dot icon of the service account you just created
    7. Select Manage Keyson the menu.
    8. Click Add Key, then Create New Key
    9. Make sure JSON is selected as the key type, and click Create
    10. Once this is created, you have your JSON file. Note the path of the file
  5. Head back to the Google Play Console module, and click Doneto close the dialog
  6. Next, select Grant Access for the newly added service account at the bottom of the screen. Try refreshing the page to reflect the latest updates if it does not show
  7. Select the permissions of your choice
  8. Invite a user to wrap up the process

Initializing Fastlane

In a standard manual application deploration instance, once you have a unique package name, the next step is to package your application for distribution, then to create a new Keystore, and so on. We will use Fastlane to handle the whole process.

To proceed, head on to the root directory of your Flutter application and initialize Fastlane for Android deployment by navigating to your Android folder directory and running the following command:

fastlane init

You will receive a prompt to input your application package name; in our case, our application name is votersapp, and the package name is com.votersapp.votersapp.

Over 200k developers use LogRocket to create better digital experiencesLearn more →

N.B., you can find your package name under the bundle.gradle file in the defaultConfig option.

Click Enterafter supplying your package name.

Using Fastlane for Flutter: A complete guide - LogRocket Blog (5)

Next, you will receive a prompt to enter the path to your JSON secret file. Input the path to the JSON file we downloaded above. Alternatively, if you are yet to obtain your JSON file, click Enterto skip this step.

Using Fastlane for Flutter: A complete guide - LogRocket Blog (6)

Next, you will receive a notification or pop-up asking if you intend to upload any metadata or screenshots; for this demonstration, we will not be uploading those, so input “n”.

Using Fastlane for Flutter: A complete guide - LogRocket Blog (7)

Hit Enterto set up the rest of the initialization from here on.

Once complete, we will see a Fastlane folder in the Android directory. Within this is an Appfile and a fastfile. Follow the process to initialize Fastlane for iOS. The Fastlane file contains all Fastlane configuration tools.

To fetch all the Google Play store metadata, run:

fastlane supply init

Now, to deploy our application to the Play Store, navigate to the project’s directory and execute the following command in the terminal:

flutter clean && flutter build apk

Deploying the application for testing

To demonstrate the capabilities of Fastlane, we will deploy our APK to Firebase App Distribution. We can perform testing and CI/CD using the Fastlane application.

Now, we will set up our Firebase project. To do this, follow these steps:

  1. Head on to Google Firebase Consoleand create an account if you do not already have one
  2. Click Create a project
  3. Specify your project name and click Continue
  4. On the menu sidebar to the left, select App Distributionand the Android icon
  5. Click Register application
  6. Specify the same package name as specified in your application for the package name. If you are not using any Firebase services, skip downloading the google-services.json file
  7. Click Continue to register App Distribution for your project
  8. Your setup should look like this:
    Using Fastlane for Flutter: A complete guide - LogRocket Blog (8)
  9. Finally, head to the tester and group section and create a new group. Then, add a new tester to the group

To assign Flutter app distribution to Fastlane, execute the following command in your terminal:

fastlane app_plugin firebase_app_distribution

In your Fastlane file, replace the existing code with the code below. This code will ensure you map Fastlane distribution to deploy to Firebase.

default_platform(:android)platform :android do desc "Deploy to Firebase app distribution" lane :deploy do begin firebase_app_distribution( groups: "testers", release_notes: "Fixing bug in features", apk_path: "../build/app/outputs/flutter-apk/app-release.apk", firebase_cli_path: "/usr/local/bin/firebase", firebase_cli_token: <FIREBASE_CLI_TOKEN> app: <YOUR_APP_ID> ) end endend

Run the command below in your terminal and grant Firebase access to get your Firebase CLI token in the above code.

firebase login:ci

Copy and replace it as the value for firebase_cli_token in the code above.

N.B., this is secret and should be kept safe.

Get your App ID from the Firebase console.

Next, we will deploy our application by specifying the lane we wish to deploy.

In the code we placed in our Fastlane file, we deploy the value for the “Lane” field. So, to execute a deployment in other lanes, we will tell Fastlane to run that particular lane. To deploy our application using Fastlane, we implement the command here:

fastlane deploy.

The command above will upload the APK specified in that particular lane. Once completed, you can head to your Firebase console and view your application deployed using Fastlane.

Using Fastlane for Flutter: A complete guide - LogRocket Blog (9)

Conclusion

Fastlane is simple and easy to implement — as I noted in the introduction, it saves hours of deployment time and is extremely useful.

In this article we have demonstrated the process of installing and initializing Fastlane and deploying our application for testing. Check on the official documentation to learn more about Fastlane. Happy coding!

Cut through the noise of traditional error reporting with LogRocket

LogRocket is a digital experience analytics solution that shields you from the hundreds of false-positive errors alerts to just a few truly important items. LogRocket tells you the most impactful bugs and UX issues actually impacting users in your applications.

Then, use session replay with deep technical telemetry to see exactly what the user saw and what caused the problem, as if you were looking over their shoulder.

LogRocket automatically aggregates client side errors, JS exceptions, frontend performance metrics, and user interactions. Then LogRocket uses machine learning to tell you which problems are affecting the most users and provides the context you need to fix it.

Focus on the bugs that matter — try LogRocket today.

Using Fastlane for Flutter: A complete guide - LogRocket Blog (2024)

FAQs

Why should I use fastlane? ›

fastlane is an open-source tool aimed at simplifying Android and iOS deployment by automating large portions of your mobile release workflows. It's an extensible framework that comes with many prebuilt actions for common tasks, and it gives you the ability to create your own actions if needed as well.

Is fastlane CI CD tool? ›

fastlane is a powerful tool that helps streamline your build process across your organisation. It can be used along side your existing CI/CD pipelines or as a standalone pipeline script to be used on your local machines or custom pipeline tools such as Buildkite.

How do you use fastlane on Android? ›

Setting up Fastlane
  1. Run fastlane init ( Initializes Fastlane in our project)
  2. Provide the package name for your application when asked (e.g. com. ...
  3. Press enter when asked for the path to your json secret file.
  4. Answer 'n' when asked if you plan on uploading info to Google Play via Fastlane (we can set this up later)

Is fastlane technology good? ›

FastLane Technology offers maximum Wi-Fi performance. It provides high-speed Wi-Fi with a dedicated band connecting the extender and the Wi-Fi device, and a second band connecting the extender and the Wi-Fi router. FastLane Technology is ideal for HD gaming and HD video streaming.

Is fastlane owned by Google? ›

Fastlane was acquired by Google on Jan 18, 2017 .

Is fastlane a CI or CD? ›

Introduction. In order to achieve CI/CD, we will be using Jenkins(CI Server) + Fastlane(CD).

What companies use fastlane? ›

Fast Lane / Directions is an authorized training partner of AWS, Aruba,Cisco, Fortinet, Gigamon, Google Cloud, KnowBe4, (ISC)², Microsoft, NetApp, Palo Alto, Splunk, VMware and other leading vendors.

Who uses fastlane? ›

Who uses fastlane? 233 companies reportedly use fastlane in their tech stacks, including KAVAK, Bitpanda, and Stack.

How do you use the fast lane? ›

What is Fast Lane? Fast Lane tickets allows earlier entry to an event. Look for the Fast Lane entry at the venue, and show your ticket and Fast Lane voucher to get in earlier. All Fast Lane ticket holders will be allowed to go in before all other fans when the doors open.

How do I use fastlane plugin? ›

Add a plugin to your project
  1. Add the plugin to fastlane/Pluginfile.
  2. Make sure your fastlane/Pluginfile is properly referenced from your ./Gemfile.
  3. Run fastlane install_plugins to make sure all required dependencies are installed on your local machine (this step might ask for your admin password to install Ruby gems)

How do I access fastlane? ›

To log in to FastLane, go to www.fastlane.gov. Click on “Proposal, Awards, and Status” at the top and then enter log in information in the PI/Co-PI Log In section.

How do you start a fastlane proposal? ›

To create a proposal, on the FastLane Home Page screen, log in to Proposals, Awards, and Status as a PI (see PI/Co-PI Login). Click Proposal Functions, then click Proposal Preparation, then click Create Blank Proposal.

Top Articles
Latest Posts
Article information

Author: Fredrick Kertzmann

Last Updated:

Views: 5862

Rating: 4.6 / 5 (66 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Fredrick Kertzmann

Birthday: 2000-04-29

Address: Apt. 203 613 Huels Gateway, Ralphtown, LA 40204

Phone: +2135150832870

Job: Regional Design Producer

Hobby: Nordic skating, Lacemaking, Mountain biking, Rowing, Gardening, Water sports, role-playing games

Introduction: My name is Fredrick Kertzmann, I am a gleaming, encouraging, inexpensive, thankful, tender, quaint, precious person who loves writing and wants to share my knowledge and understanding with you.