Firebase - Tool Setup

  1. Objectives
  2. Video
  3. Introduction
  4. Installing and configuring Firebase tools
  5. Next Steps

Objectives

Video

https://youtu.be/pJzV0DCvxqA

Introduction

Firebase is Google’s mobile computing platform. It provides a variety of services, including user authentication, file storage, and databases that would normally be coded in some sort of remote web application. These services are in such demand that providers such as Google Firebase, Amazon Web Services, and Microsoft Azure have been created to provide these services with minimal custom code, and instead replaced that with a lot of client-side configuration and the use of language-specific libraries to communicate with the services.

AWS, Azure, and Firebase are the biggest names in integrated cloud service. You could use any that you like. In this class, we are using Firebase for a few reasons:

Installing and configuring Firebase tools

Adding Firebase to our app requires installing and configuring Flutter libraries and setting up a Firebase project in the cloud for your app to use. The instructions below are distilled from https://firebase.google.com/docs/flutter/setup?platform=android.

You only need to do this step once for each development machine that you use.

  1. Sign into Firebase using your Google account.
  2. Install the Firebase Command-Line Interface (CLI):
    • For Mac/Linux
      1. Open a Terminal and run the following command:

      curl -sL https://firebase.tools | bash

    • For Windows on a Personal Machine
      1. If you already have Node.js v14.18.0 or later installed, go to Step 3.
        • Otherwise, download nvm-setup.exe and run the installer. Install using the default settings.
        • Open a Command Prompt/Powershell/Terminal and run nvm install lts. This will install the latest version of Node.js on your computer. You may need to run the Command Prompt as an Administrator if you have permissions issues.
        • After installation, you will see a command Installation complete. If you want to use this version, type nvm use xx.yy.zz.Type the nvm use xx.yy.zz command.
      2. Run the command

      npm install -g firebase-tools

    • For Windows on a Lab Machine
      1. Download and unzip Node.js. Move the unzipped folder to a permanent location, like your Desktop or Home folder.
      2. Hit the Windows key and type ‘environment’. Select the “Edit environment variables for your account” option.
      3. An “Environment Variables” window will pop up. In the top pane, select the ‘Path’ variable and click Edit.
      4. Click the ‘New’ button then the ‘Browse’ button.
      5. In the Browse for folder, navigate to the folder where you unzipped Node.js to.
      6. Open a Command Prompt/Powershell/Terminal and run the command

      npm install -g firebase-tools

  3. In the Terminal (Mac) or Command Prompt (Windows), run firebase login. Follow the on-screen instructions and complete the login process in your browser when it pops up. you will see a confirmation message of “Logged in as: your.email@gmail.com”.
    • If the command cannot be found, try closing and reopening the Terminal/Command Prompt for the Path changes to take effect.
  4. In the Terminal/Command Prompt, run the command dart pub global activate flutterfire_cli
  5. Edit your Path:
    • For Windows only:
      1. Hit the Windows key and type ‘environment’. Select the “Edit environment variables for your account” option.
      2. Click the “Environment Variables” button at the bottom.
      3. An “Environment Variables” window will pop up. In the bottom pane, select the ‘Path’ variable and click Edit.
      4. Click the ‘New’ button then the ‘Browse’ button.
      5. In the Browse for folder, go to This PC/Windows (C:)/*YourLogin* (e.g., laymanl)/AppData/Local/Pub/cache/bin. Hit “Ok” to close out these screens.
    • For Mac/Linux only:
      1. For Mac: type nano ~/.zshrc
      2. For Linux: type nano ~/.bashrc
      3. Go to the bottom of the file by pressing your “Page Down” or Down Arrow key repeatedly. Hit Enter to create a new blank line at the end of the file.
      4. Enter the following exactly:
        export PATH="$PATH":"$HOME/.pub-cache/bin"
        
      5. Hit Control+X. If asked, hit Y to save changes. Hit Enter to save the file.
  6. Close VSCode if you have it open so that changes will take effect.

Next Steps

You only need to configure the Firebase tools once per development computer that you use.

Now that the tools are ready, continue to Firebase - Per App Configuration to add Firebase to your app.