VOOZH about

URL: https://www.geeksforgeeks.org/android/user-authentication-using-firebase-in-android/

⇱ User authentication using Firebase in Android - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

User authentication using Firebase in Android

Last Updated : 12 Jul, 2025

Firebase is a platform that helps developers build mobile and web apps. It provides useful tools like databases, cloud storage, and hosting. One of its main features is email and password login, so developers don’t have to create their own system for user authentication. This makes app development easier, faster, and more secure.

Step by Step Implementation:

Step 1: Create a new project and Connect to Firebase app

Refer to Adding firebase to android app and follow the steps to connect firebase to your project.

Step 2: Enable Email/Password Authentication in Firebase Console

Go to Firebase console and navigate to your project, and under Project Overview, scroll down.

Select Authentication and Click on Get Started on the next screen.

πŸ‘ Authentication

Select Email/Password under Sign-in method > Native providers.

πŸ‘ emailpassword

Enable Email/Password sign-in and click on Save.

Step 3: Add Firebase Authentication SDK to your project

Go to Tools > Firebase which should open the Firebase Assistant tab. Then Select Authentication > Authentication using Google. On the next screen, select Add the Firebase Authentication SDK to your app. Select Accept Changes on the dialog box that appears next. This will add the necessary dependencies of Firebase Authentication to your app.

πŸ‘ authentication-sdk

Step 4: Working with RegisterActivity and it's layout

Create a new activity by right clicking on app folder, then New > Activity> Empty views activity. Then add the following code to the RegisterActivity file in Java or Koltin and the xml code to the activity_register.xml file.

Design UI:

πŸ‘ register-screen


Step 5: Working with LoginActivity and it's layout

Create a new activity by right clicking on app folder, then New > Activity> Empty views activity. Then add the following code to the LoginActivity file in Java or Koltin and the xml code to the activity_login.xml file.

Design UI:

πŸ‘ Login-screen

Step 6: Working with MainActivity and it's layout

Navigate to app > java > package name > MainActivity and app > res > layout > activity_main.xml. Then add the following code to the MainActivity file in Java or Koltin and the xml code to the activity_main.xml file.

Design UI:

πŸ‘ design-ui-main

Output:

Note: If you face any unknown compilation error while running the app, consider downgrading the Firebase auth dependency in build.gradle.kts from 23.2.0 to 21.0.1

A new user will be added to Users section in Authentication.

πŸ‘ email-authentication


Comment

Explore