Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to sign in with Google #25

Closed
hanskokx opened this issue Feb 17, 2021 · 5 comments
Closed

Unable to sign in with Google #25

hanskokx opened this issue Feb 17, 2021 · 5 comments

Comments

@hanskokx
Copy link

hanskokx commented Feb 17, 2021

auth: ^7.3.2
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19042.804], locale en-US)

I'm unable to sign in with Google while using your example code. (To be fair,) I'm wedging it into my existing application.

The first thing I noticed was that this:

auth = Auth.init(
      scopes: [
        'email',
...

was telling me The method 'init' isn't defined for the type 'Auth', which I thought was strange. So, I removed .init, and moved on.

Next, I plopped your code into my sign-in page.

RaisedButton(
  onPressed: () {
    auth
        .signInWithGoogle()
        .then((signIn) => signInFunc(signIn: signIn))
        .catchError((Object err) {
      if (err is! Exception) {
        err = err.toString();
      }
      errorMessage = auth.message;
    });
  },
  child: const Text('Sign In With Google'),
),

The app compiles and runs, but when I tap the Sign In With Google button, I get the following error:

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

I didn't have google_sign_in in my pubspec.yaml, so I added it thinking that might be the problem, but it hasn't helped.

Any suggestions?

@hanskokx
Copy link
Author

More info:

  • I tried to delete my Android directory and run flutter create ., but that didn't fix the problem.
  • I tried to replace main.dart with the file in your example folder, but that didn't work, either.
  • I found a plugin in my pubspec.yaml that referenced facebook login, and got rid of it before trying either of the aforementioned options.
  • The contents of my pubspec.yaml are as follows:
environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  async: ^2.4.2
  auth: ^7.3.2
  cloud_firestore: null
  firebase_core: ^0.7.0
  firebase_crashlytics: ^0.4.0+1
  flutter_dotenv: ^3.1.0
  google_sign_in: ^4.5.9
  modal_progress_hud: ^0.1.3
dev_dependencies:
  flutter_test:
    sdk: flutter

@hanskokx
Copy link
Author

@Andrious
Copy link
Member

Just got in...reading your messages now.

@Andrious
Copy link
Member

I'd recommend updating Dart to 2.10.0. That's the latest version in the Stable channel.
Further, I'd just assign the major version number with trailing zeros: .0.0 to the dependencies.
That'll keep your dependencies up-to-date with the latest minor updates and bug fixes.

pubspec.yaml file: ( The dependencies I feel I didn't need, I commented out. )

environment:
  sdk: ">=2.10.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  animated_text_kit: ^3.0.0
#  async: ^2.0.0
  auth: ^7.0.0
  cloud_firestore: ^0.16.0
  cupertino_icons: ^1.0.0
#  firebase_auth: ^0.20.0
#  firebase_core: ^0.7.0
  firebase_crashlytics: ^0.4.0
#  flutter_automation: ^1.0.0
  flutter_dotenv: ^3.0.0
#  flutter_svg: ^0.19.0
#  google_sign_in: ^4.0.0
  modal_progress_hud: ^0.1.0

Running under Android, I had to enable the Multi-Dex
\punk_messenger\android\app

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.punk_messenger"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName 
        multiDexEnabled true                                    <-----------  add this line.
    }

Finally, while in the directory where the pubspec.yaml file resides, delete the ios/ and android/ directories and run flutter create . to re-generate these directories.

@hanskokx
Copy link
Author

The issue is resolved now. There were a few things that might have contributed.

https://github.com/hanskokx/Punk-Messenger/commit/2d4f78e433e643d706b6842c6cb9dced0d88eab9
https://github.com/hanskokx/Punk-Messenger/commit/1d6bf41e7e327d03f1bee0cfaf6b4cd0101868c5

Those are the commits with the changes I made. Now that I'm getting "proper" error messages from auth, I can at least confidently state that the problem doesn't appear to be related to the package. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants