BMX*_*BMX 7 google-authentication react-native firebase-authentication
我正在 React Native 中实现 google 身份验证,但即使在执行所有步骤之后,我仍然遇到相同的错误:
本机模块 RNGoogleSignin 试图覆盖 RNGoogleSigninModule 错误
代码中没有重复!我不知道为什么它在我尝试运行后一直显示这个错误。
这就是我导入的方式:
import co.apptailor.googlesignin.RNGoogleSigninPackage;
Run Code Online (Sandbox Code Playgroud)
这就是我在 getPackages() 中添加它的方式
packages.add(new RNGoogleSigninPackage());
Run Code Online (Sandbox Code Playgroud)
mzp*_*cha 10
就我而言,这是由于我自己做的非常愚蠢的问题。
我有 2 个版本的 react native google sigin。我用这些命令安装
yarn add @react-native-community/google-signin
yarn add react-native-google-signin
Run Code Online (Sandbox Code Playgroud)
卸载 react-native-google-sigin 后,我的问题解决了。我知道这很旧,但可能值得某人使用。
小智 2
您使用的是哪个版本的 React Native?
如果您使用的是 0.60 或更高版本,则不需要执行packages.add(new RNGoogleSigninPackage());,因为该库是自动链接的。
如果您需要在 MainApplication 中添加该库getPackages()(可能是因为您正在使用密钥实例化包,或者您遇到自动链接问题),您可以这样做。您可以通过将包添加到项目根目录中指定的文件中的依赖项列表中来阻止包自动链接react-native.config.js(如果没有,您应该创建它)。
如果您想禁用 的自动链接react-native-google-signin,您react-native.config.js应该如下所示:
module.exports = {
dependencies: {
'react-native-google-signin': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1813 次 |
| 最近记录: |