bizz84 / firebase_auth_demo_flutter

Reference Authentication Flow with Flutter & Firebase
https://codewithandrea.com/
MIT License
674 stars 178 forks source link

Using code with new project throws exception #58

Closed mblaughton closed 4 years ago

mblaughton commented 4 years ago

Great project, thanks!

However when I tried to use this code in a freshly created project using Flutter 1.17.1 (stable) it throws the following exception whenever I tap "Sign in with Google". It also happens when signing out.

Debug console:

W/FlutterActivity(26934): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@d756c5d) but could not find and invoke the GeneratedPluginRegistrant.

Exception:

MissingPluginException (MissingPluginException(No implementation found for method init on channel plugins.flutter.io/google_sign_in))

When I use the project as-is from github it works perfectly, but thought you'd like to know there may be an issue with new projects going forward, at least on Android. It appears they recently changed how plugins are embedded, which I suspect is related to this regression.

To reproduce:

  1. flutter create my_project
  2. Replace contents of lib, assets, and pubspec.yaml with yours (but with firebase_auth: ^0.16.0 and google_sign_in: ^4.4.4)
  3. Drop in google-services.json, etc...
  4. Launch app and tap "Sign in with Google"

Expected: Should sign in like the official github project Actual: Throws above error/exception

The exception is being triggered on the following line in firebase_auth_service.dart, specifically in the signIn() function: final GoogleSignInAccount googleUser = await googleSignIn.signIn();

I'm continuing to troubleshoot and will update if I find anything, but wanted to let you know.

mblaughton commented 4 years ago

Update: I don't understand why yet, but removing the flutter_facebook_login package from pubspec.yaml (and commenting out all references to it) fixes the problem with the call to googleSignIn.signIn(). Possibly a namespace collision somewhere within?

clivolive commented 4 years ago

Hello, Have you set up the facebook sign method on firebase?

mblaughton commented 4 years ago

So... that worked. And now I'm laughing for two reasons:

  1. In a million years I would never have guessed that completing the Facebook config would fix my Google exception.
  2. You convinced me to create a Facebook account with just 11 words. This, after 15 years of telling my friends and family I had no interest in ever joining Facebook. :smile:

Thanks for the help!

clivolive commented 4 years ago

Yeah, confused the heck out of me too.