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.
Run flutter clean
and restart IDE as well as re-buid app completely . This will fix it.
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
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
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 -->
For me it was to install pods again
Open terminal inside flutter project diractory and write
cd ios
pod install
It happened recently on beta channel of Flutter repository. consider check out from stable channel.
我一次尝试了很多东西,所以我不太确定,但我想这解决了问题。
flutter_facebook_login: ^3.0.0 -> remove this one
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.