react-native-google-signin / google-signin

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

**NON-FIREBASE:** 1: Task failed with an exception. Execution failed for task ':app:processDebugGoogleServices'. > Missing project_info object #1184

Closed thianphat closed 1 year ago

thianphat commented 1 year ago

Steps to Reproduce

npm run android

Just run npm run android

Expected Behavior

I know it says NOT to use the google-services.json file if you aren't using Firebase, but I also run into another build error when the file is not included. Please see below.

Actual Behavior

WITH google-services.json

Does not build. I get this error:

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
Missing project_info object

The issue occurs when trying to build the android version of the app. I've already built the iOS app and tested it and it works. I have the google-services.json file in the root directory of my project. The containing json object is as follows:

{
  "installed": {
    "client_id": "*****.apps.googleusercontent.com",
    "project_id": "*****",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
  }
}

I realize that the project_info object does not exist when downloading the json file from the Google API dashboard. I've read online that Firebase will provide this project_info object, but I am not using Firebase for my DB. Is there a workaround for this? I've read through the documentation and could not find an answer. **

WITHOUT google-services.json

per the troubleshooting docs: for non-firebase users it says to not include the google-services.json file nor make any changes to the gradle files but WITHOUT the google-services.json file in the root directory, i get this error:

✖ Config sync failed Error: [android.dangerous]: withAndroidDangerousBaseMod: Cannot copy google-services.json from /Users/***/***/google-services.json to /Users/***/***/android/app/google-services.json. Please make sure the source and destination paths exist.

Could someone please help? I've tried the recommended steps without Firebase and read through the documentation for hours on end and cannot find a solution.

Environment

Please provide

vonovak commented 1 year ago

Hello @thianphat It sounds like you're using expo.

I belive the right workaround is to download the Google services json file from firebase and use that.

Hope it helps 👍

thianphat commented 1 year ago

Hello @thianphat It sounds like you're using expo.

I belive the right workaround is to download the Google services json file from firebase and use that.

Hope it helps 👍

Hi, so do I download the file from Firebase then replace it with my Google API info? Can you explain what parts of the file I should replace since I don't use Firebase.

vonovak commented 1 year ago

just download and use that file, that's it. No replacements.

thianphat commented 1 year ago

just download and use that file, that's it. No replacements.

Okay, thanks that seemed to work for building without any errors.

So, what I did was I created a Firebase project using the current Google API project as the basis following these instructions

However, the data returned back is undefined. For iOS I get the user data back, but on Android nothing is returned after logging into Google. It seems like the line const userInfo = await GoogleSignin.signIn(); is not working as intended. See video here.

My code is as so:

    const signIn = async () => {
        try {
            await GoogleSignin.hasPlayServices();
            console.log(GoogleSignin.hasPlayServices())
            const userInfo = await GoogleSignin.signIn();
            setUserInfo({ userInfo });
            console.log("Google Auth Info", userInfo)
        } catch (error) {
            if (error.code === statusCodes.SIGN_IN_CANCELLED) {
                // user cancelled the login flow
                console.log(error)
            } else if (error.code === statusCodes.IN_PROGRESS) {
                // operation (e.g. sign in) is in progress already
                console.log(error)
            } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
                // play services not available or outdated
                console.log(error)
            } else {
                // some other error happened
            }
        }
    };

This function also returns false for Android

    const isSignedIn = async () => {
        const isSignedIn = await GoogleSignin.isSignedIn();
        console.log("Signed in?",isSignedIn, Device.osName)
    };
vonovak commented 1 year ago

Hello, it sounds pretty weird that you'd get undefined back.

But knowing that, it's not surprising that calling const isSignedIn = await GoogleSignin.isSignedIn(); returns false.

If you've added the json file from firebase and it's still not working, I advice you go over the setup docs here https://github.com/react-native-google-signin/google-signin/blob/master/docs/android-guide.md

If that does not help, you can get in touch with me via email and I can help you out, as a paid service.

Thank you! :)

thianphat commented 1 year ago

Hello,

it sounds pretty weird that you'd get undefined back.

But knowing that, it's not surprising that calling const isSignedIn = await GoogleSignin.isSignedIn(); returns false.

If you've added the json file from firebase and it's still not working, I advice you go over the setup docs here https://github.com/react-native-google-signin/google-signin/blob/master/docs/android-guide.md

If that does not help, you can get in touch with me via email and I can help you out, as a paid service.

Thank you! :)

Thanks, I emailed you.

Do I need to make changes to the gradle files as shown in the instructions?

vonovak commented 1 year ago

Hello and thanks for asking, closing this as we resolved the issue via personal communication.

Thank you 🙂

igorrmon commented 1 year ago

Hello! @vonovak can you show how resolved it?

I have the same problem! But in my case i use CLI With "react-native": "0.72.4",