react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.18k stars 877 forks source link

GoogleSignin.signIn() not resolving and not throwing error on physical device #1324

Closed stephengladney closed 1 week ago

stephengladney commented 2 weeks ago

I have searched open and closed issues for this issue.

This is not a bug report for DEVELOPER_ERROR

Minimal reproducible example

https://github.com/stephengladney/pare

What platform(s) does this occur on?

Android

Summary

When calling GoogleSignin.signIn() on a development build in Android emulator, the promise resolves and a user is returned. When running the app on an Android device in production (internal testing), the promise doesn't resolve and no error is thrown. Attached is a video of a development build running on Emulator and a production build running on a physical device. Both are Pixel 3XL on Android 12.0.

Note: Github repo is linked but private. I can provide access to specific project contributors upon request.

const handleGoogleSignInPress = async () => {
    try {
      GoogleSignin.configure({
        scopes: ["email"],
        webClientId:
          "XXXXXXXXXXXXXXXXXXXX",
      })
      const userInfo = await GoogleSignin.signIn()
      const user = await getUserByAccountId(userInfo.user.id as string)

      if (user) await handleExistingUser(user)
      else await handleNoExistingUser(userInfo.user.id)
    } catch (e) {
      alert(e)
      console.error(e)
    }
  }

// Component calling the above function:

<GoogleSigninButton
  size={GoogleSigninButton.Size.Wide}
  color={GoogleSigninButton.Color.Dark}
  onPress={handleGoogleSignInPress}
  disabled={false}
/>

Working on development build on Emulator:

https://github.com/user-attachments/assets/8aa2bd55-102a-461a-8c2a-49b0a3ce4427

Not working on physical Android device:

https://github.com/user-attachments/assets/e09510c5-c809-4aa5-ae07-506e6e6c6da0

Your computer environment

System: OS: macOS 11.7.10 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 463.48 MB / 16.00 GB Shell: version: "5.8" path: /bin/zsh Binaries: Node: version: 21.1.0 path: /usr/local/bin/node Yarn: version: 1.22.19 path: /usr/local/bin/yarn npm: version: 10.5.2 path: /usr/local/bin/npm Watchman: version: 2024.04.15.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms:

stephengladney commented 2 weeks ago

Worth noting, the Android OAuth credential's SHA-1 fingerprint is using the fingerprint from my Upload key certificate in Google Play Console. Should this be the fingerprint from the App signing key certificate? Would using the upload key certificate work in dev builds but not releases from Google Play?

vonovak commented 2 weeks ago

Hello and thanks for asking, can you attach the logs? I'm quite certain that the error will be logged there. using alert for debugging is not reliable because it relies on currentActivity which might be null when returning from the sign in activity.

Re your question: Do the docs answer it? https://react-native-google-signin.github.io/docs/setting-up/get-config-file#obtain-sha-1-certificate-fingerprints (what could make them better?) Thank you 🙂

stephengladney commented 2 weeks ago

Hello and thanks for asking, can you attach the logs? I'm quite certain that the error will be logged there. using alert for debugging is not reliable because it relies on currentActivity which might be null when returning from the sign in activity.

Re your question: Do the docs answer it? https://react-native-google-signin.github.io/docs/setting-up/get-config-file#obtain-sha-1-certificate-fingerprints (what could make them better?) Thank you 🙂

The app is not outputting any logs/activity. Other apps do output activity so it's not a hardware issue.

Screen Shot 2024-08-30 at 2 39 30 PM
vonovak commented 2 weeks ago

Hi, apologies for not clarifying that, I meant android logs. Specifically logcat. One of these methods should work for that. For RN console logs, you'll see logs that start with ReactNativeJS, if I remember correctly.

Also, change the console.error(e) to something more verbose and easily searchable like console.error('myRNerror', e.code, e.mesage).

If you can share those then I can take a look. Hope this helps.

stephengladney commented 2 weeks ago

Hi, apologies for not clarifying that, I meant android logs. Specifically logcat. One of these methods should work for that. For RN console logs, you'll see logs that start with ReactNativeJS, if I remember correctly.

Also, change the console.error(e) to something more verbose and easily searchable like console.error('myRNerror', e.code, e.mesage).

If you can share those then I can take a look. Hope this helps.

08-30 17:40:05.448 27847 27847 W com.notld.pare: ClassLoaderContext classpath size mismatch. expected=12, found=5 (DLC[];PCL[base.apk*465103810:base.apk!classes2.dex*2629239628:base.apk!classes3.dex*3922910124:base.apk!classes4.dex*2067847664:base.apk!classes5.dex*2847858866:base.apk!classes6.dex*1405884365:base.apk!classes7.dex*1188508838:base.apk!classes8.dex*1749931297:base.apk!classes9.dex*4211147046:base.apk!classes10.dex*1713483948:base.apk!classes11.dex*197585008:base.apk!classes12.dex*2986376733]{PCL[/system/framework/org.apache.http.legacy.jar*2058259660]#PCL[/system/framework/com.android.media.remotedisplay.jar*3472798122]#PCL[/system/framework/com.android.location.provider.jar*3633238673]#PCL[/system/framework/org.apache.http.legacy.jar*2058259660]} | DLC[];PCL[/data/app/~~cZV-mQTl2loLGAp6JQfKjg==/com.notld.pare-OwF0MwetTpB8ggAaQqBFQA==/base.apk*2489410112:/data/app/~~cZV-mQTl2loLGAp6JQfKjg==/com.notld.pare-OwF0MwetTpB8ggAaQqBFQA==/base.apk!classes2.dex*4029419200:/data/app/~~cZV-mQTl2loLGAp6JQfKjg==/com.notld.pare-OwF0MwetTpB8ggAaQqBFQA==/base.apk!classes3.dex*2974904285:/data/app/~~cZV-mQTl2loLGAp6JQfKjg==/com.notld.pare-OwF0MwetTpB8ggAaQqBFQA==/base.apk!classes4.dex*4166128927:/data/app/~~cZV-mQTl2loLGAp6JQfKjg==/com.notld.pare-OwF0MwetTpB8ggAaQqBFQA==/base.apk!classes5.dex*2788657312])
08-30 17:40:07.679  1640  4025 I ActivityTaskManager: START u0 {act=com.google.android.gms.auth.GOOGLE_SIGN_IN pkg=com.notld.pare cmp=com.notld.pare/com.google.android.gms.auth.api.signin.internal.SignInHubActivity (has extras)} from uid 10211
08-30 17:40:08.638  1640  2168 W InputManager-JNI: Input channel object 'dc572ba com.notld.pare/com.google.android.gms.auth.api.signin.internal.SignInHubActivity (client)' was disposed without first being removed with the input manager!
stephengladney commented 2 weeks ago

It appears that calling GoogleSignin.signOut() after getting the necessary data returned by GoogleSignin.signIn() has resolved the issue.