I am using the google_sign_in plugin in a flutter app to sign in. Using code from the example The code for signing in is just:
GoogleSignIn _googleSignIn = new GoogleSignIn(
scopes: <String>[
'email',
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive.metadata',
],
);
Future<Null> _handleSignIn() async {
print("_handleSignIn");
try {
await _googleSignIn.signIn();
} catch (error) {
print("We failed");
print(error);
}
}
This works on Android. I press the signin button and there is a popup and I get to signin.
But, this simple example crashes on iOS. When the app calls _handleSignIn
above, the _googleSignIn.signIn()
call crashes the app (it goes away) with the error message:
flutter: _handleSignIn
*** First throw call stack:
(
0 CoreFoundation 0x000000010fe581e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010f4ed031 objc_exception_throw + 48
2 CoreFoundation 0x000000010fecd975 +[NSException raise:format:] + 197
3 Runner 0x000000010ce61d8b -[GIDSignIn signInWithOptions:] + 242
4 Runner 0x000000010ce5e777 -[GIDSignIn signIn] + 64
5 Runner 0x000000010ce591b2 -[FLTGoogleSignInPlugin handleMethodCall:result:] + 2114
6 Flutter 0x000000010d1af716 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 118
7 Flutter 0x000000010d1c5370 _ZNK5shel<…>
Lost connection to device.
I have no experience building iOS apps so, I probably did something wrong. I followed the instructions and added the GoogleService-Info.plist
from firebase.com and updated my Info.plist
as instructed.
Any ideas? Any way to get a better error message so I can figure out what might be wrong?
My case was I updated GoogleService-Info.plist
but forgot to update CFBundleURLTypes
according to REVERSED_CLIENT_ID
in Info.plist
.
Just had the same problem. It was because I added Google & Facebook login.
Adjust Info.plist. Search for CFBundleURLTypes
. You will see you have it TWICE. That is wrong. From the Facebook one, copy the <string>fb??????????????</string>
part and paste it into the same array in the Google Part. Then remove the CFBundleURLTypes
from the Facebook part.
If you just follow the instructions from Google Login & Facebook login, then you will paste a CFBundleURLTypes
section for Google and one for Facebook. Only the latter one will be picked up. So the google one is not in there. So when trying to log in with google sign in, it will raise the exception because it is not correctly setup. Because the google url scheme got overwritten with the facebook one.
Related issues that helped me figure out the problem:
Not sure what the problem was. I did it all over again and now it works. Maybe it was a cut-n-paste error.
The only new thing I did was set the Team, in the General tab, to my Personal Team. Previously it was unset. No idea if this matters or not.
If you successfully moved GoogleService-Info.plist
to the right directory and added CFBundleURLTypes
into your Info.plist
and still experience crashes then the reason might be in google_sign_in package itself.
There is a known issue with this package on iOS devices (Futter issue)
Long story short: a user named @buuth found that there is a simple lack of null checks for properties hostedDomain
and clientId
, so you just need to explicitly set them.
GoogleSignIn googleSignIn = GoogleSignIn(
scopes: ['email','profile'],
hostedDomain: "",
clientId: "",);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With