firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.6k stars 3.95k forks source link

[firebase_auth]: signInWithProvider does not return to the app on Android Emulator #13089

Open JCKodel opened 1 month ago

JCKodel commented 1 month ago

Is there an existing issue for this?

Which plugins are affected?

Auth

Which platforms are affected?

Android

Description

Using this code:

final provider = AppleAuthProvider();

provider.addScope("email");
provider.addScope("name");

final userCredential = await FirebaseAuth.instance.signInWithProvider(
  provider,
);

On a real device, the browser opens, I log in to my Apple account, then it returns to my app with currentUser filled. All normal.

On Android emulator, the behaviour is different: the user IS authenticated, but the browser doesn't close, and it goes back to the sign-in page. Everything works fine (I am authenticated), but the browser never redirects back to the app.

Reproducing the issue

Use the code above on an Android Emulator.

I'm using Windows with a Pixel 3, Android 13.

Firebase Core version

3.2.0

Flutter Version

3.22.3

Relevant Log Output

I/GenericIdpActivity(16326): Opening IDP Sign In link in a browser window.
W/System  (16326): A resource failed to call end. 

### Flutter dependencies

<!--- Look below for instructions on how to share your Flutter Dependencies. --->

<details>
<summary>Expand <code>Flutter dependencies</code> snippet</summary>
<br>

```yaml

Dart SDK 3.4.4
Flutter SDK 3.22.3
enterprise 0.1.0

dependencies:
- device_info_plus 10.1.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- firebase_auth 5.1.2 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 3.2.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- hugeicons 0.0.5 [flutter]
- vector_graphics 1.1.11+1 [flutter http vector_graphics_codec]

dev dependencies:
- flutter_lints 4.0.0 [lints]
- vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path]

transitive dependencies:
- _flutterfire_internals 1.3.39 [collection firebase_core firebase_core_platform_interface flutter meta]
- args 2.5.0
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- clock 1.1.1
- collection 1.18.0
- device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.2
- file 7.0.0 [meta path]
- firebase_auth_platform_interface 7.4.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.12.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 5.1.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.17.3 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- google_identity_services_web 0.3.1+1 [meta web]
- google_sign_in_android 6.1.27 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.7.6 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.4.5 [flutter plugin_platform_interface]
- google_sign_in_web 0.12.4+1 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- http 1.2.2 [async http_parser meta web]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- leak_tracker 10.0.4 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.3 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 4.0.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.8.0 [collection]
- meta 1.12.0
- path 1.9.0
- path_parsing 1.0.1 [vector_math meta]
- petitparser 6.0.2 [meta]
- plugin_platform_interface 2.1.8 [meta]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- string_scanner 1.2.0 [source_span]
- term_glyph 1.2.1
- test_api 0.7.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- vector_graphics_codec 1.1.11+1
- vector_math 2.1.4
- vm_service 14.2.1
- web 0.5.1
- win32 5.5.1 [ffi]
- win32_registry 1.1.3 [ffi win32]
- xml 6.5.0 [collection meta petitparser]

Additional context and comments

No response

Lyokone commented 1 month ago

Hey @JCKodel, I was able to reproduce but still unsure about how to fix this. Might be something with a specific Android emulator version.

JCKodel commented 1 month ago

Hey @JCKodel, I was able to reproduce but still unsure about how to fix this. Might be something with a specific Android emulator version.

The important part is that you are aware.

Just FYI, I'm using the emulator that came with latest Android Studio:

Android version: 13.0 (T) - API 33 Emulator version: 34.2.16-12038310

saviourdog commented 1 month ago

I also have this problem on the real machine, can't go back to the app