Tuesday, 5 August 2025

Firebase Phone Auth Not Working on Emulator ??

 


๐Ÿงฉ Problem Statement:

You're trying to implement Phone Number Authentication in Flutter with Firebase :

  • ✅ In Firebase Console test phone number and verification code set correctly 

  • OTP screen flashes for a split second in the Mobile App

  • ❌ Then you’re redirected to Chrome browser, without being able to enter the OTP



  • ❌ Or app seems to "hang" or fail silently

This can mislead developers into thinking the Firebase setup is broken, when in fact — it's an emulator problem.



๐ŸŽฏ Root Cause:

The problem arises when your emulator doesn't have Google Play Services.

Firebase Phone Auth uses Google Play Services to manage:

  • reCAPTCHA flows

  • SafetyNet checks

  • SMS auto-retrieval and manual entry screen

Without it, Android redirects to a browser to complete verification — which often fails silently in the emulator.


✅ Verified Fix (Working Emulator Setup):

1. Delete Any Emulator Without Google Play

Go to Android Studio > Device Manager
๐Ÿ—‘️ Delete emulators that don’t show “Google Play” in the “Play Store” column.

2. Create a New Emulator (Pixel 6a Recommended)

  • Click “Create Virtual Device”

  • Choose a modern Pixel (Pixel 6a works great)

  • Proceed to System Image screen

3. Select the Correct System Image

✅ Choose:

API 33 | Google Play | x86_64

Look for these clues:

  • ✅ “Google Play” tag in green

  • ✅ “Play Store” column shows a checkmark after creation

  • ✅ Emulator shows Play Store icon on home screen

4. Check SDK Components (One-Time)

Open Android Studio > SDK Manager > SDK Tools tab.
Ensure the following are installed:

  • ☑️ Google Play Services

  • ☑️ Android SDK Platform for API 33

  • ☑️ Intel x86 Emulator Accelerator

  • ☑️ Android Emulator

Then restart Android Studio.




๐Ÿงช Test the Flow Again

  1. Launch your new emulator

  2. Run your Flutter app

  3. Initiate Phone Auth

  4. ✅ You’ll now see the OTP entry screen stay and function properly — no Chrome redirection!


๐Ÿ› ️ Summary

If your Firebase Phone Auth:

  • ✅ Sends OTP

  • ❌ Flashes the OTP screen

  • ❌ Redirects to Chrome

๐Ÿ‘‰ You are likely using an emulator without Google Play Services.

Fix it by switching to a Google Play system image (e.g., Pixel 6a, API 33 with Google Play).