I am implementing google authentication in React Native but even after following all the steps I keep getting the same error:
Native module RNGoogleSignin tried to override RNGoogleSigninModule error
There is no duplicate in the code! I have no idea why it keeps showing this error after I try to run it.
This is how I am importing:
import co.apptailor.googlesignin.RNGoogleSigninPackage;
And this is how I am adding it in the getPackages()
packages.add(new RNGoogleSigninPackage());
In my case it was due to very stupid problem did by myself.
I had 2 versions of react native google sigin. I installed with these commands
yarn add @react-native-community/google-signin
yarn add react-native-google-signin
After uninstalling react-native-google-sigin my problem got solved.I know this is old but might be worthy for someone.
What version of React Native are you on?
If you're on 0.60 or later, you shouldn't need to do packages.add(new RNGoogleSigninPackage());
, since the library is auto-linked.
If you NEED to add that library in the MainApplication's getPackages()
(maybe because you're instantiating the package with a key, or you have issues with auto-linking), you can do so. You can stop packages from being auto-linkd by adding them to the list of dependencies, in the file named react-native.config.js
in the root of your project (if you don't have it, you should create it).
If you want to disable auto-linking for react-native-google-signin
, your react-native.config.js
should look something like this:
module.exports = {
dependencies: {
'react-native-google-signin': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
Can confirm this is caused by duplicate google-sign-in and google auth duplicated in package.json
The cause of this is autolinking just remove any duplicates in your package.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With