You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo React Native Google登录配置报错:RN GoogleSignin模块未正确链接

解决Expo + React Native Google登录模块未正确链接问题

问题重现

配置Google登录时添加以下代码:

GoogleSignin.configure({
  webClientId: '',
  offlineAccess: true,
});

触发错误:

Error: RN GoogleSignin native module is not correctly linked. Please read the readme, setup and troubleshooting instructions carefully.
If you are using Expo, make sure you are using Custom dev client, not Expo go., js engine: hermes

已使用expo-dev-client,确认模块链接,尝试过官方文档方法及npx expo install react-native-google-signin/google-signin,问题仍存在。项目package.json内容如下:

{
  "name": "second_project",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "11": "^0.0.1",
    "@expo/vector-icons": "^13.0.0",
    "@expo/webpack-config": "^19.0.0",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/datetimepicker": "7.2.0",
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-firebase/app": "^18.7.3",
    "@react-native-firebase/auth": "^18.7.3",
    "@react-native-google-signin/google-signin": "^11.0.0",
    "@react-native-picker/picker": "2.4.10",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/material-top-tabs": "^6.6.5",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/stack": "^6.3.20",
    "@reduxjs/toolkit": "^1.9.7",
    "@types/react-redux": "^7.1.31",
    "expo": "~49.0.13",
    "expo-auth-session": "~5.0.2",
    "expo-build-properties": "~0.8.3",
    "expo-camera": "~13.4.4",
    "expo-crypto": "~12.4.1",
    "expo-doctor": "^1.1.3",
    "expo-file-system": "~15.4.5",
    "expo-google-sign-in": "^11.0.0",
    "expo-image-picker": "~14.3.2",
    "expo-permissions": "^14.2.1",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "firebase": "^10.7.1",
    "link": "^2.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "^0.72.6",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-gifted-chat": "^2.4.0",
    "react-native-google-signin": "^2.1.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-link": "^4.1.0",
    "react-native-pager-view": "6.2.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^3.5.2",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^10.0.2",
    "react-native-web": "~0.19.6",
    "react-redux": "^8.1.3",
    "redux": "^4.2.1",
    "redux-saga": "^1.2.3",
    "typescript": "^5.1.3",
    "yet": "^0.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react-native": "^0.72.8"
  },
  "private": true
}

解决方案

1. 清理冲突的Google登录依赖

你的package.json中同时存在4个不同版本/来源的Google登录相关包,这是导致模块链接冲突的核心原因。执行以下命令卸载重复包:

npm uninstall @react-native-community/google-signin react-native-google-signin expo-google-sign-in

只保留@react-native-google-signin/google-signin,这是Expo dev client环境下的官方推荐包。

2. 重新安装并校验依赖

rm -rf node_modules package-lock.json yarn.lock
npm install
npx expo install @react-native-google-signin/google-signin

3. 清理缓存并重建开发客户端

npx expo prebuild --clean
npx expo run:android

4. 修正配置细节

  • 确保webClientId填写的是Google Cloud控制台中Web应用的客户端ID,而非Android应用ID
  • 检查Google Cloud控制台:已启用Google登录API,且Android应用的SHA-1指纹已正确添加到项目的OAuth 2.0客户端ID配置中

5. 清理无用依赖

移除package.json中明显无效的依赖(如11、link、yet),避免干扰依赖树结构。

内容的提问来源于stack exchange,提问作者Vinit Kumar Rathore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 04:35:04