3
votes

After debugging for multiple hours without any result at all, I have given up. I have been learning Flutter by creating an application that connects to a Firebase realtime database, which work in debug mode and local installation through adb. But whenever I (or any of my friends) install the package though something else than adb (such as package manager or something else) I am gettings issues.

For starters, here is the relevant part of my pubspec.yaml:

dependencies:
  google_sign_in: 3.2.1
  firebase_auth: 0.5.20
  firebase_core: 0.2.5

At the beginning of my statefull widget:

final FirebaseAuth _fAuth = FirebaseAuth.instance;
final GoogleSignIn _gSignIn = new GoogleSignIn();
final DatabaseReference database = FirebaseDatabase.instance.reference().child("users");

And the relevant part of my code:

googleSignInAccount = await _gSignIn.signIn(); // [1]
authentication = await googleSignInAccount.authentication; // [2]

...

_firebaseUser = await _fAuth.signInWithGoogle(
    idToken: authentication.idToken,
    accessToken: authentication.accessToken);

...

So the problem is that, with a bit older 3.0.5 version of the google_sign_in package, I get the error:

PlatformException(sign_in_failed, Status{statusCode=CANCELED, resolution=null}, null)

Already at point [1], even though the login dialog was never cancelled, just after selecting a google account to use. This never happens in debug mode, as if google rejects the production application on login. When I update the google_sign_in package to version 3.2.1, I get the following message at point [2]:

NoSuchMethodError: The getter 'authentication' was called on null.
Receiver: null
Tried calling: authentication

Which means step [1] does not result in an error any more, but just returns null, and as such it fails at step [2]. I do not have this problem in debug mode, so there should be nothing wrong with the login flow.

Note: I do use a local signing keystore, but I never had any issue with that. Note 2: I also made an issue with them since I can't find anything at all that looks like my issue, see here.

1

1 Answers

0
votes

See the issue pages (here) that this is resolved by updating to google_sign_in version 3.2.2 which gave a clear error, so I could actually solve this.

In the end this has nothing to do with flutter itself (though it and the google_sing_in library were not helping) but with keystores. Always keystores.