Open GubendranVins opened 3 years ago
I am facing the same problem. Have you fixed it?
Any solution for the above issue?
Try this line of code will help:
GoogleSignIn.DefaultInstance.SignIn().ContinueWith( OnAuthenticationFinished, TaskScheduler.FromCurrentSynchronizationContext());
Hey, I've solved the problem. Basically, the crash happens for me because of 2 things:
1 - When call GoogleSignIn.DefaultInstance.SignOut();
but the user is not logged in the GoogleSignIn. This only will not crash, but if you try calling GoogleSignIn.DefaultInstance.SignIn()
after it will.
2 - GoogleSignIn.Configuration
get lost for some reason.
To fix this problem I pass the configuration every time before calling the SignIn
and the SignInSilently
methods. And when the app initializes I validate if the user is logged with auth.CurrentUser
and get the provider FirebaseUser.ProviderData.GetEnumerator()
. If google.com
is one of the providers I call SignInSilently
.
private void Awake() {
configuration = new GoogleSignInConfiguration {
WebClientId = webClientId,
RequestIdToken = true
};
}
public async Task<bool> IsUserAuthenticated()
{
if (auth.CurrentUser != null)
{
if(auth.CurrentUserIsAnonymous) {
// User is Anonymous
}
if(GetProvider() == 'google.com') {
GoogleSignIn.Configuration = configuration;
await GoogleSignIn.DefaultInstance.SignInSilently();
}
return true;
}
return false;
}
public string GetProvider() {
var enumerator = AuthData.FirebaseUser.ProviderData.GetEnumerator();
while (enumerator.MoveNext()) {
var provider = enumerator.Current.ProviderId;
if (provider != 'firebase')
return provider;
}
}
Then whenever you call GoogleSignIn.DefaultInstance.SignIn()
pass the configuration first like this:
GoogleSignIn.Configuration = configuration;
await GoogleSignIn.DefaultInstance.SignIn(); // or SignInSilently()
For the future users Repeated same by enabling Minify - Release (and fixed it by unchecking said item)
Try this line of code will help:
GoogleSignIn.DefaultInstance.SignIn().ContinueWith( OnAuthenticationFinished, TaskScheduler.FromCurrentSynchronizationContext());
It's works for me. Nice job
Hey, I've solved the problem. Basically, the crash happens for me because of 2 things:
1 - When call
GoogleSignIn.DefaultInstance.SignOut();
but the user is not logged in the GoogleSignIn. This only will not crash, but if you try callingGoogleSignIn.DefaultInstance.SignIn()
after it will.2 -
GoogleSignIn.Configuration
get lost for some reason.To fix this problem I pass the configuration every time before calling the
SignIn
and theSignInSilently
methods. And when the app initializes I validate if the user is logged withauth.CurrentUser
and get the providerFirebaseUser.ProviderData.GetEnumerator()
. Ifgoogle.com
is one of the providers I callSignInSilently
.private void Awake() { configuration = new GoogleSignInConfiguration { WebClientId = webClientId, RequestIdToken = true }; } public async Task<bool> IsUserAuthenticated() { if (auth.CurrentUser != null) { if(auth.CurrentUserIsAnonymous) { // User is Anonymous } if(GetProvider() == 'google.com') { GoogleSignIn.Configuration = configuration; await GoogleSignIn.DefaultInstance.SignInSilently(); } return true; } return false; } public string GetProvider() { var enumerator = AuthData.FirebaseUser.ProviderData.GetEnumerator(); while (enumerator.MoveNext()) { var provider = enumerator.Current.ProviderId; if (provider != 'firebase') return provider; } }
Then whenever you call
GoogleSignIn.DefaultInstance.SignIn()
pass the configuration first like this:GoogleSignIn.Configuration = configuration; await GoogleSignIn.DefaultInstance.SignIn(); // or SignInSilently()
It worked like a charm! Thanks
Hi , We have implement the google login using firebase sdk in unity. I have implement the sign in flow complete and it's working in my android mobile on first time app open time. After am close the app. Open again and try to sign-out and try sign in again the unity app was crashed with below warnings, please advice how to solve this problem.
Crash Warning Report :
java.lang.Error: FATAL EXCEPTION [UnityMain] Unity version : 2019.4.16f1 Device model : Xiaomi Redmi Note 6 Pro Device fingerprint: xiaomi/tulip/tulip:9/PKQ1.180904.001/V12.0.1.0.PEKMIXM:user/release-keys Caused by: java.lang.Error: Version '2019.4.16f1 (e05b6e02d63e)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a' Build fingerprint: 'xiaomi/tulip/tulip:9/PKQ1.180904.001/V12.0.1.0.PEKMIXM:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: 2021-08-03 13:19:26+0530 pid: 29894, tid: 29928, name: UnityMain >>> com.cmpy.appname <<< uid: 10369 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference x0 0000000000000000 x1 0000006f6f15d9b0 x2 0000006f6f000000 x3 0000000000000003 x4 000000000000015d x5 00000070707a2004 x6 00000070707a6604 x7 000000000e705a34 x8 00000070707a6604 x9 2486b7a058ac9246 x10 00000000000000e0 x11 0000000000000000 x12 000000000000018c x13 00676e69646e6550 x14 000000712e13b000 x15 0000007132498000 x16 000000712f12cbc8 x17 000000712f0adb14 x18 000000707eb38000 x19 0000007076021b48 x20 000000707eb28000 x21 0000006f6f1b45e0 x22 000000707d73d9cc x23 0000000000000001 x24 00000070907c5c78 x25 0000000000000000 x26 00000070907c7588 x27 0000000000000001 x28 00000070907c6538 x29 00000070907c5c50 sp 00000070907c5c10 lr 000000707cc592e0 pc 00000070707a6608 backtrace:
00 pc 000000000000b608 /data/app/com.cmpy.appname-vfSUZsfRwws3Rkbon6Z0ww==/lib/arm64/libnative-googlesignin.so (GoogleSignIn_Pending+4) (BuildId: a093eb15516d5796589d881687a62d11f1763a1c)