react-native-google-signin / google-signin

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

RNGoogleSignin.signIn got 2 arguments, expected 3 #1123

Closed MicahDavid closed 1 year ago

MicahDavid commented 1 year ago

This problem occurs on my android build. I have no problems in dev mode, but the app crashes in the release version when signIn() is executed.

Steps to Reproduce

useEffect(() => {
      GoogleSignin.configure()
}, [])
await GoogleSignin.hasPlayServices()
await GoogleSignin.signIn()
const tokens = await GoogleSignin.getTokens()

Expected Behavior

Google Sign In dialogue would appear, and app would not crash

Actual Behavior

App crashes

Environment

MicahDavid commented 1 year ago

When I added: buildTypes { release { debuggable true

Then, I dont get the error on the release version. What does this say regarding this error?

MicahDavid commented 1 year ago

I've figured out that the error occurs during:

await GoogleSignin.hasPlayServices()

not

await GoogleSignin.signIn()

I made sure the play services was up to date on the device.

MicahDavid commented 1 year ago

works as expected on iOS emulator.

github-actions[bot] commented 1 year ago

:wave: @MicahDavid, sorry you're having an issue. As the issue template explains, we require that you provide a runnable example that reproduces your issue (please read the issue template). The reason is that maintainers do not have time to try reproduce bugs themselves. Please try to minimize the superfluous code and focus only on reproducing the bug. Please create a new issue with this and we'll be happy to review it! If you're hitting a hard wall, you may consider paid assistance.

MicahDavid commented 1 year ago

It would be nice if you could leave these issues open, so that others may find/comment on them even though there isn't a public repo to reproduce the problem. I noticed there was another closed issue with the same problem, so it would certainly be nice if the community could support each other in such cases.

MicahDavid commented 1 year ago

I was able to fix this by cleaning out the project.

I did: yarn cache clean

and also ran:


Wipe iOS build folder? (Y/n) n
Wipe iOS Pods folder? (Y/n) n
Wipe system iOS Pods cache? (Y/n) n
Wipe user iOS Pods cache? (Y/n) n
Update pods? (Y/n) n
Wipe android build folder? (Y/n) n
Clean Android project? (Y/n) Y
Wipe node_modules folder? (Y/n) Y
Update brew? (Y/n) n```

Not sure if both methods were needed, but this got things working for me. 
MicahDavid commented 1 year ago

I'm updating this, because my previous cache clean was only helping for the dev build. In production, I couldn't get the app to update from my code changes. The problem was that for React Native 0.70.6, you must use gradle 7.2.2. I was using 7.3.1. This was really the source of the problem.

A note to be careful when Android Studio asks to upgrade your gradle version, because this can throw everything off. Also, in the React Native docs, I only recall the docs saying to use 7.2.2 or higher. Turns out this didn't work.

The interesting thing is that even though the app was not updating to my latest code changes, all of the other functionality was working, except for the Google Sign In, so the gradle change had a signficant influence on this particular package. Hope this helps someone else who falls into this trap.