I’m experiencing an issue with Google Sign-In in my Flutter application. When attempting to sign in with Google, I receive a PlatformException. Here’s the error log:
W/Auth (10169): [GoogleAuthUtil] [GoogleAuthUtil] error status:UNKNOWN with method:getTokenWithDetails
...
I/flutter (10169): error: PlatformException(exception, ERROR, null, null)
E/flutter (10169): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(exception, ERROR, null, null)
E/flutter (10169): #0 GoogleSignInApi.getAccessToken (package:google_sign_in_android/src/messages.g.dart:250:7)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169): #1 GoogleSignInAndroid.getTokens.<anonymous closure> (package:google_sign_in_android/google_sign_in_android.dart:68:15)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169): #2 GoogleSignInAccount.authentication (package:google_sign_in/google_sign_in.dart:95:9)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169): #3 GoogleLoginProvider.getAuthCredential (package:firebase_manager/src/auth/login/providers/google_login_provider.dart:15:11)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169): #4 LoginTool.loginByGoogle (package:firebase_manager/src/auth/login/login_tool.dart:36:37)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169): #5 StatePage.build.<anonymous closure> (package:saiwai/ui/loginpage/login_page.dart:80:42)
E/flutter (10169): <asynchronous suspension>
E/flutter (10169):
I’ve tried the following steps to resolve the issue:
- Updated all dependencies to their latest versions
- Checked and updated the SHA-1 fingerprint in the Firebase console
- Verified the Firebase configuration files (google-services.json)
- flutter clean
Despite these efforts, the error persists. I’m using the latest stable version of Flutter and testing on an Android device.
Here’s a snippet of my code where the error occurs:
Future<OAuthCredential?> getAuthCredential() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await googleSignIn.signIn();
if (googleUser != null) {
// Obtain the auth details from the request
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
// Create a new credential
return GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
}
return null;
}
Can anyone suggest what might be causing this issue or how to further diagnose and resolve it? Any help would be greatly appreciated.
2
Answers
similar problem, yesterday this code still worked, today it doesn’t, in all my applications that I haven’t updated for several months with this code they show an error:
[log] PlatformException: exception – ERROR – null
This worked for me