flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[auth]: web-context-already-presented error on Android due to android:taskAffinity=""

Open passsy opened this issue 1 month ago • 3 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

Which plugins are affected?

Auth

Which platforms are affected?

Android

Description

This is a followup to the closed/locked issue https://github.com/firebase/flutterfire/issues/13297 which I ran into. The chrome custom tab disappears when I switch apps (e.g. to open my password manager) and opening the login again returns the error web-context-already-presented.

https://github.com/user-attachments/assets/19aa7e52-2c5c-44f1-b8c0-36b2859839a5

The solution to that is mentioned here: https://github.com/MaikuB/flutter_appauth/issues/503#issuecomment-2165906205

Remove android:taskAffinity="" from the AndroidManifest.xml


The firebase_auth sdk should detect this, and show a waning

Reproducing the issue

Reproducible in the firebase_auth example application https://github.com/firebase/flutterfire/tree/main/packages/firebase_auth/firebase_auth/example

Using signInWithProvider.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';

class SampleScreen extends StatelessWidget {
  const SampleScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          child: const Text("Login"),
          onPressed: () async {
            final provider = TwitterAuthProvider(); // or any other that opens a webview
            await FirebaseAuth.instance.signInWithProvider(provider);
          },
        ),
      ),
    );
  }
}

Firebase Core version

3.13.0

Flutter Version

3.24.5

Relevant Log Output


Flutter dependencies

No response

Additional context and comments

No response

passsy avatar Oct 30 '25 17:10 passsy