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

React Native ExpoLocation报错:期望FusedLocationProviderClient类却找到接口

解决Expo Location调用getLastKnownPositionAsync时的FusedLocationProviderClient类型错误

问题根源

这个错误是定位库依赖冲突+版本不兼容导致的:

  • 你同时引入了expo-location和react-native-geolocation-service两个定位相关库,二者都依赖Google Play Services Location模块,但版本不一致,编译时出现类型解析混乱(把类识别成了接口)。
  • 手动添加的play-services-location:16.0.0版本过低,和Expo 41的依赖版本不匹配。

分步解决方案

1. 移除冲突依赖

如果基于Expo生态开发,建议保留expo-location,移除重复的定位库:

npm uninstall react-native-geolocation-service
# 用yarn的话执行:yarn remove react-native-geolocation-service

2. 删除手动添加的低版本依赖

打开android/build.gradle,删除你手动添加的这行代码:

implementation 'com.google.android.gms:play-services-location:16.0.0'

Expo会自动管理Google Play Services相关依赖的版本,无需手动指定。

3. 清理并重新构建

  • 清理Android构建缓存:
cd android && ./gradlew clean
  • 重置本地依赖:
rm -rf node_modules package-lock.json yarn.lock
npm install
# 或 yarn install
  • 重新运行项目:
npm run android

4. 可选:对齐Google服务版本

如果问题仍存在,检查android/build.gradle中Google服务插件版本是否和Expo 41兼容,确保buildscript下的依赖为:

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.8'
    }
}

内容的提问来源于stack exchange,提问作者Gourav Mishra

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 03:30:52