VOOZH about

URL: https://www.geeksforgeeks.org/firebase/phone-number-verification-using-firebase-in-android/

⇱ Phone Number Verification using Firebase in Android - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Phone Number Verification using Firebase in Android

Last Updated : 23 Jul, 2025

Phone number Firebase Authentication is used to sign in a user by sending an SMS message to the user's phone. The user signs in using a one-time code contained in the SMS message. A sample video is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Kotlin language.

Note: All projects utilizing Firebase Phone Authentication (SMS) must be linked to a Cloud Billing account starting from September 1, 2024

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Note that select Kotlin as the programming language.

Step 2: Connect Project to Firebase.

👁 Image

Step 3: Add dependency

Navigate to Gradle Scripts > build.gradle.kts (Module :app) and add the following dependencies

dependencies {
...
implementation ("com.google.firebase:firebase-auth:23.2.0")
implementation ("com.google.android.gms:play-services-auth:21.3.0")
}

In the same file, add the following plugin

plugins {
...
id("com.google.gms.google-services")
}

Navigate to Gradle Scripts > build.gradle.kts (Project :<app name>) and add the following plugin

plugins {
...
id("com.google.gms.google-services") version "4.4.2" apply false
}

Remember to update the Kotlin version to 2.1.0 in libs.versions.toml to make it compatible with the firebase versions.

Now, sync the project to download the dependencies.


Step 4: Add internet permission

Navigate to app > manifests > AndroidManifest.xml and add the following permission.

<uses-permission android:name="android.permission.INTERNET"/>


Step 5: Working with MainActivity files

Navigate to MainActivity.kt and activity_main.xml and add the following codes.


Step 6: Add SHA keys from Android Studio to Firebase

Copy SHA1 and SHA-256 keys from your project and paste them to the firebase console. Below is the screenshot to guide you.

Note: Please refer to this article How to Generate SHA1, MD5, and SHA-256 Keys in Android Studio?

👁 Image


On the Firebase console go to Project Overview >  Project Setting, and click add fingerprint button, and add your SHA keys copied from firebase

👁 Image


Step 7: Enable Phone Number sign-in for your Firebase project

In the Firebase console choose your project, open the Authentication section. On the Sign-in Method page, enable the Phone Number sign-in method.

👁 Image

Output:


Comment

Explore