Firebase Authentication - 1 - Firebase setup

Welcome to the Firebase Authentication series! In this series we will create an android app that lets users register, log in and change their information. It will be divided into 10 articles:

  1. Firebase setup
  2. Layout
  3. Register and Login
  4. Reset password
  5. Verify email
  6. Change profile picture
  7. Change display name
  8. Change email
  9. Change password
  10. Delete account

When we are done you will be able to create simple android apps that can authenticate users and update their information. If you have your own layout, you can skip the second part, but I advice you to at least skim through it so you get an idea of the xml elements we are connecting with java variables. This post is about the firebase setup, before we dive in however, I want to show you what we are building.

Sneak peek

This is what the final product will look like when we are done programming after the 9 articles. A register screen, login screen, welcome screen and a main screen with a dropdown menu with options.

        

 

Firebase setup

Create a new android project if you haven't already and open up the firebase console in your browser, and add a new project there. Navigate to project settings by clicking on the top left cog next to "Project Overview", under the firebase logo.

At the bottom of the page you should see a text saying "There are no apps in your projects, select platform to get started". Click on the android icon.

This will take you to a four step page. In the first step, when registering the app, make sure you type in the correct package name. If you have created an android project you will find the package name in the very first line in your main activity. Click on register when you're done. Now you will be asked to download the google-services.json file. Download this file and place it in the correct directory, shown in the image below.

 

Click on next when done. Navigate to the project-level build.gradle, and do the following:

buildscript {
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
  }
  dependencies {
    ...
    // Add this line
    classpath 'com.google.gms:google-services:4.3.3'
  }
}

allprojects {
  ...
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
    ...
  }
}

Make sure that you got the latest version, chances are that it have been updated by the time you read this.

Next, navigate to the app-level build.gradle and do the following:

apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'

dependencies {
    ...

    // Firebase auth
    implementation 'com.google.firebase:firebase-auth:19.3.1'
}

Again, make sure that you got the latest version. You can find the latest version here. Sync the gradle files and make sure you don't get any errors. Find this beautiful icon in you android studio window and click on it to sync:

 

Enable Email/Password

Now we need to enable the Email/Password option in the firebase console so people can sign in with email. Click on the Authentication option in firebase console, it should be located just under "Project Overview" where we clicked on the cog before. Next, click on the Sign-in method tab. Click on Email/Password, and a popup should show up. Hit Enable and save.

The setup is complete! In the next article we will build the layout for the app.

Author

authors profile photo

Articles with similar tags

thumbnail
Firebase Authentication - 7 - Change display name

Changing a display name in Android Studio with firebase auth

By Frogitecture

thumbnail
Firebase Authentication - 8 - Change email

Changing email in Android with Firebase Authentication

By Frogitecture

thumbnail
Firebase Authentication - 9 - Change password

Changing a password in Android with Firebase Authentication

By Frogitecture

thumbnail
Firebase Authentication - 10 - Delete account

Deleting an account in Android with Firebase Authentication

By Frogitecture