react-native-google-signin / google-signin

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

TypeError: Cannot read property 'SIGN_IN_CANCELLED' of null, js engine: hermes #1217

Closed NataliiaRybalka closed 7 months ago

NataliiaRybalka commented 7 months ago

I have a react-native project. I want to add Google auth. I have this modules: "@react-native-google-signin/google-signin": "^10.1.0", "@react-native-firebase/app": "^18.6.1" And this code:

import { useEffect } from 'react';
import { GoogleSignin, statusCodes, GoogleSigninButton } from '@react-native-google-signin/google-signin';

function LoginGoogle({ setErr, navigation }) {
    useEffect(()=>{
        GoogleSignin.configure({
            webClientId: '416637401596-babo0cnot3u9pam1eam5l5huh01pnj35.apps.googleusercontent.com', 
        })  
    },[]);

    const googleLogin = async () => {
        try {
            await GoogleSignin.hasPlayServices();
            const userInfo = await GoogleSignin.signIn();
            console.log("userinfo", userInfo);

        } catch (error) {
            if (error.code === statusCodes.SIGN_IN_CANCELLED) {
                console.log(error)
            } else if (error.code === statusCodes.IN_PROGRESS) {
                console.log(error)
            } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
                console.log(error)
            } else {
            }
        }
    };

    return (
        <View>
            <Pressable onPress={googleLogin}>
                <Text style={{color: '#222222',fontWeight:'400',fontSize:18}}>
                    Login with Google
                </Text>
            </Pressable>
        </View>
    );
}

export default LoginGoogle;

In android/build.gradle I added:

buildscript {  
   ...
   dependencies {
        ...
    classpath('com.google.gms:google-services:4.4.0')
    }
}

In android/app/build.gradle I added:

dependencies {
    implementation(platform("com.google.firebase:firebase-bom:32.5.0"))
        ...
}

After that, when I start the app I have the error "TypeError: Cannot read property 'SIGN_IN_CANCELLED' of null, js engine: hermes". App can not even start. Please, help me to resolve it!

lucianolopezz commented 7 months ago

Same

alexnguyennz commented 7 months ago

How are you running the app? You can get this error if you're using Expo Go.

NataliiaRybalka commented 7 months ago

The module @react-native-google-signin/google-signin works only with running npx react-native start. For expo I used the module expo-auth-session.

lucianolopezz commented 7 months ago

The module @react-native-google-signin/google-signin works only with running npx react-native start. For expo I used the module expo-auth-session.

Google signin with expo-auth-session is Deprecated. The expo docs recommend use @react-native-google-signin/google-signin.

github-actions[bot] commented 7 months ago

:tada: This issue has been resolved in version 10.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: