Skip to content
Related Articles

Related Articles

How to Setup Firebase Email Authentication in Android with Example

Improve Article
Save Article
  • Last Updated : 21 Aug, 2022
Improve Article
Save Article

Service-access permissions are configured using a mechanism called Firebase authentication. This is accomplished by using Google’s Firebase APIs and Firebase console to create and manage legitimate user accounts. You’ll discover how to integrate Firebase authentication into an Android application in this article.

Step By Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. The code for that has been given in both Java and Kotlin Programming Language for Android.

To do this, launch Android Studio and Create an Empty Activity Project with the following configurations:

  • Name: Geeks for Geeks Auth.
  • Package name: as com.<your_name>.firebaseauth (without spaces).
  • Language: Kotlin.
  • Minimum SDK: API 24: Android 7.0
Firebase Email Authentication in Android


Step 2: Signing in to Android Studio

Find the login button in the right corner, and then tap login to log in to your firebase account.


Step 3: Creating a Firebase Project

A Firebase project is required, which we will later link to our Android app. We will have access to the majority of Firebase services through this project, including authentication and analytics.

There are various steps in this process:

  1. Launch Firebase, log in using your Google account, and then click the button in the top right corner to get to Firebase Console.
  2. Create a new firebase project, with the name of the project, like the one below:

Image #3: Creating a new project.

        3. Enable the analytics:

Image #4: Enabling the analytics.

Step 4: Connecting Firebase with the Application

A Firebase project can be linked to an Android app in two different methods.

  1. Adding the services configuration file by hand
    You can accomplish this by downloading the google-services.json file, inserting it into the root of the Android project, and manually adding the required dependencies.
  2. You need a running app for this process so that it can communicate with the firebase servers. This shows that the dependencies and project configuration files are functioning as intended. 
  3. Using the Firebase Assistant in Android Studio
    This approach takes care of the majority of the work for you and is simpler and more direct. We’ll employ this approach because it is straightforward.
  4. You can then follow this guide to connect firebase to your app.

Step 5: Adding the Firebase Dependencies

Image #5: Adding the Dependencies

classpath ''  // Google Services plugin

apply plugin: ''  // Google Services plugin

// Import the Firebase BoM
implementation platform('')

There is one additional Firebase-related detail. We need to enable email and password authentication in our project’s console because we wish to use it. 

Go to Authentication > Sign-in method and activate email and password authentication to accomplish that. This is how it ought to seem.

Image #6: Enabling authentication on the project.


The configuration of Firebase authentication is complete.

Step 6: Adding the Code Sauce

We will now develop the user interface (UI) and backend for our application. Here’s where Kotlin and XML come into play. The firebase APIs will handle the server-side backend for us, so we don’t need to code anything. Isn’t that fantastic?

We need to keep our app organized first. The term “application architecture” refers to this. The three new packages to be added are extensions, utils, and views. Expand the java directory, right-click on the package name directory, and choose to add.

As we go forward, we’ll find out more about them.

Step 7: Working with activity_main.xml

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.


<?xml version="1.0" encoding="utf-8"?>
        app:layout_constraintTop_toTopOf="parent" />
        app:layout_constraintVertical_chainStyle="packed" />
        app:layout_constraintTop_toBottomOf="@id/etEmail" />
        app:layout_constraintTop_toBottomOf="@id/etPassword" />

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!