My Android Flutter app has Google sign-in using Firebase Authentication. Everything works great in debug mode, but fails in release mode. I have added my SHA-1 fingerprints for both debug and release keystores in the Firebase console, and have updated to the latest google-services.json.
The problem seems to be that I am never getting a FirebaseUser back. This method always returns null:
Future<FirebaseUser> _getCurrentUser() async {
FirebaseAuth firebaseAuth = FirebaseAuth.instance;
if (firebaseAuth.currentUser() != null) {
return await firebaseAuth.currentUser();
}
return null;
}
The codelabs example isn't working either. It is returning a GoogleSignInUser, but it's not creating a Firebase user in the console:
Future<GoogleSignInAccount> _ensureLoggedIn() async {
GoogleSignInAccount user = _googleSignIn.currentUser;
if (user == null) user = await _googleSignIn.signInSilently();
if (user == null) {
user = await _googleSignIn.signIn();
analytics.logLogin();
}
if (_auth.currentUser == null) {
GoogleSignInAuthentication credentials =
await _googleSignIn.currentUser.authentication;
await _auth.signInWithGoogle(
idToken: credentials.idToken,
accessToken: credentials.accessToken,
);
}
return user;
}
I have implemented Firebase Authentication before in a native Android app just fine. I have read several other stack overflow posts about this, but I feel like I have tried everything. Any help would be appreciated!
UPDATE:
In a release build, I can read and write to the database if I don't set any read/write rules. I am still unable to create a FirebaseUser. I can create a GoogleSignInAccount, but that doesn't create a Firebase user.