Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native module RNGoogleSignin tried to override RNGoogleSigninModule error

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());
like image 600
BMX Avatar asked Aug 24 '19 02:08

BMX


3 Answers

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.

like image 74
mzparacha Avatar answered Dec 24 '22 03:12

mzparacha


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
      },
    },

  },
};


like image 24
Enzo Monjardin Avatar answered Dec 24 '22 03:12

Enzo Monjardin


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

like image 32
Jose Salas Avatar answered Dec 24 '22 04:12

Jose Salas