17

Using Flutter's google sign_in

But seeing the following message when I use this statement to sign in a user

_googleSignIn.signIn();

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

I verified the following steps:

GoogleSignInPlugin.registerWith(registry.registrarFor("io.flutter.plugins.googlesignin.GoogleSignInPlugin")); // is present

GeneratedPluginRegistrant.registerWith(this); // in MainActivity.Java

Is this error frequently reported by users. Not sure how to proceed. I am doing what most of the docs say and yet it doesn't work.

Other weird behavior I see is, first time I run flutter run it gets stuck on await googleSignIn.SignIn().

Only after I do a hot reload (by typing "r"), I see the above error message of :

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

Question: Are there any alternatives to do basic auth on Flutter applications. I just need some kind of basic auth so that my server can know which user it is serving data to.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
user462455
  • 12,838
  • 18
  • 65
  • 96

10 Answers10

23

Run flutter clean and restart IDE as well as re-buid app completely . This will fix it.

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
  • 1
    After doing this I can no longer run my program. Ugh! – tazboy Mar 20 '20 at 18:48
  • 1
    After doing `flutter clean` either do `flutter install` or you'll need to build first `flutter build ios` for iOS. I'm only developing in iOS at the moment so I'm not sure how it goes for android. Maybe `flutter build android` – Mikebarson Aug 06 '21 at 06:26
13

I have been smashing my head over this problem when I encountered it. Finally I realized what I was doing wrong. I had to do the following steps
1>Switch to the master branch
flutter channel master
2>flutter upgrade
3>flutter clean
4>And the most important part, check if you have the facebook plugin. If yes, either set it up completely(not tested) or remove it(works) as it messes with the google plugin

Andrii Turkovskyi
  • 27,554
  • 16
  • 95
  • 105
Siddharth Agrawal
  • 2,960
  • 3
  • 16
  • 37
  • 1
    It is not a good idea to switch to the `master` branch. The `stable` branch is optimal because it is... well, stable. You might encounter bugs at any other branch. However, correctly setting up facebook plugin does the trick (at least it did for me). If it is not correctly setup it will make itself as well as other plugins throw that exception. – hman_codes Sep 16 '20 at 17:58
  • 2
    Changing of branch didn't help. Removing FB auth helped with Google auth. Finally setting up the FB has helped to solve the issue – Andrii Turkovskyi Sep 22 '20 at 08:48
  • #4 was really important – Germa Vinsmoke Dec 12 '20 at 16:48
  • Yup that is the only thing different from others. The other steps are just to make sure you have not made a simple mistake. That is why I mentioned it was the most important – Siddharth Agrawal Dec 14 '20 at 17:18
  • Just go straight to step #4! – Igor JS Feb 13 '21 at 23:02
  • Thanks a ton, you are a real saviour. I was scratching my head for hours over this problem and the solution was the goddamn facebook plugin. – Abhishek Mar 27 '21 at 16:46
4

Turns out you don't have to remove flutter_facebook_login to make google_signin work. This happens when flutter_facebook_login throws during registration and prevents google_sign_in from registering as told by flutter's official repo's contributor here.

The solution as provided in one of the comments of that thread is to register Facebook plugin in AndroidManifest.xml, which I also forgot. Registering Facebook in manifest fixed the issue.

The code to add in manifest is:

<meta-data android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id"/>

<activity android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name" />

<activity
    android:name="com.facebook.CustomTabActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>
</activity>

Don't forget to add the required strings in strings.xml as

<string name="app_name">Your App Name</string>  <!-- app name on fb -->
<string name="facebook_app_id">Your FB ID</string>  <!-- fb app id -->
<string name="fb_login_protocol_scheme">Your FB protocol scheme</string>  <!-- fb+ fb app id -->
Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50
  • 1
    This one adding at AndroidManifest.xml actually solved the problem. Removing `flutter_login_facebook` or `flutter_facebook_auth` from pubspec when I installed along side with `google_sign_in` works temporarily. – Htoo Maung Thait Aug 21 '21 at 09:17
3

finally I found issue with in flutter, because conflict between google and facebook login pub

in pubspec.yaml file

google_sign_in: ^4.5.3

flutter_facebook_login: ^3.0.0 -> remove this one

and comment all the code for facebook login

1

For me it was to install pods again

Open terminal inside flutter project directory and write

cd ios
pod install
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Husam
  • 8,149
  • 3
  • 38
  • 45
1

EDIT: As per Git Issue #80874, It looks like Google and Facebook can now be used together.

OLD REMARK: My flutter application was working nice and well, until I added:

flutter_facebook_login: ^3.0.0

After searching a while Flutter's Github issue #62639 and #61166, made it clear that currently Google Sign In and Facebook Login plugins can't be used together.

0

It happened recently on beta channel of Flutter repository. consider check out from stable channel.

0

Remember after installing a plugin in a flutter project, hot reload or restart will throw this error (missing plugin exception), you need to rerun the app! Hot reload is supported for only pure dart code, plugins contain native code like java or swift, which must be available for the dart code so recompile is the only option to push the native code to app running on the device.

Yadu
  • 2,979
  • 2
  • 12
  • 27
0

You can Stop the application and try with this commands

1 flutter doctor
Fix if something is wrong

2 flutter clean
3 flutter run -v

-1

I've tried many things at once so I'm not quite sure, but I guess this fixed the problem.

flutter_facebook_login: ^3.0.0 -> remove this one
Altaf
  • 2,838
  • 1
  • 16
  • 8
Zerclk
  • 1
  • 1