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:
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.
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.
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:
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
2020-06-18
Changing a display name in Android Studio with firebase auth
Changing email in Android with Firebase Authentication
Changing a password in Android with Firebase Authentication
Deleting an account in Android with Firebase Authentication