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

Expo 51中ExpoLocation.startLocationUpdatesAsync调用失败求助

Expo Location后台更新报错排查:ERR_UNEXPECTED初始化任务消费者失败

使用ExpoLocation.startLocationUpdatesAsync时触发以下错误,导致无法后台捕获用户位置:

Caused by: rd.c: Initializing task consumer 'fd.b' failed. Inherited error: fd.b.<init> [class android.content.Context, interface fc.e]] code: 'ERR_UNEXPECTED'

环境配置信息

Expo版本

Expo 51

package.json依赖

"@expo/config-plugins": "~8.0.0",
"@fortawesome/fontawesome-svg-core": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/pro-light-svg-icons": "^6.5.2",
"@fortawesome/pro-regular-svg-icons": "^6.5.2",
"@fortawesome/pro-solid-svg-icons": "^6.5.2",
"@fortawesome/pro-thin-svg-icons": "^6.5.2",
"@fortawesome/react-native-fontawesome": "^0.3.2",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.9",
"@react-navigation/stack": "^6.3.20",
"@react-navigation/tabs": "^0.0.0-alpha.12",
"axios": "^1.6.5",
"base-64": "^1.0.0",
"core-js": "^3.36.0",
"date-fns": "^3.3.1",
"expo": "~51.0.17",
"expo-asset": "~10.0.6",
"expo-barcode-scanner": "^13.0.1",
"expo-build-properties": "~0.12.3",
"expo-camera": "~15.0.12",
"expo-dev-client": "~4.0.19",
"expo-jwt": "^1.6.5",
"expo-location": "^17.0.1",
"expo-print": "~13.0.1",
"expo-router": "~3.5.17",
"expo-secure-store": "~13.0.2",
"expo-sharing": "~12.0.1",
"expo-sqlite": "~14.0.4",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.6",
"expo-task-manager": "^11.8.2",
"jwt-decode": "^4.0.0",
"mobx": "^6.12.0",
"mobx-react-lite": "^4.0.5",
"native-base": "^3.4.28",
"react": "18.2.0",
"react-native": "0.74.2",
"react-native-gesture-handler": "~2.16.1",
"react-native-mask-input": "^1.2.3",
"react-native-modal": "^13.0.1",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "^4.10.1",
"react-native-signature-canvas": "^4.7.2",
"react-native-svg": "15.2.0",
"react-native-vector-icons": "^10.0.3",
"react-native-webview": "13.8.6"

app.json安卓权限配置

"android": {
  "permissions": [
    "android.permission.ACCESS_COARSE_LOCATION",
    "android.permission.ACCESS_FINE_LOCATION",
    "android.permission.FOREGROUND_SERVICE",
    "android.permission.FOREGROUND_SERVICE_LOCATION",
    "android.permission.ACCESS_BACKGROUND_LOCATION",
    "android.permission.WAKE_LOCK",
    "android.permission.CAMERA"
  ]
}

排查方案

  • 校验依赖兼容性:当前expo-task-manager与expo-location版本匹配Expo 51要求,但可尝试删除node_modules和锁文件后重新执行npm install/yarn install,清除依赖缓存。
  • 检查任务注册逻辑:确保调用startLocationUpdatesAsync前,已通过TaskManager.defineTask完成唯一任务注册,无重复注册或任务名称冲突情况。
  • 确认权限授权:代码中需主动调用Location.requestForegroundPermissionsAsync()和Location.requestBackgroundPermissionsAsync(),并校验用户是否完全授权后台位置权限。
  • 配置前台服务:Android 12+版本后台位置更新必须配合前台服务,需确保启动位置更新时已启动对应的前台服务(可通过expo-task-manager配置或自定义实现)。
  • 清除项目缓存:执行npx expo start --clear清理Expo缓存后,重新打包测试。
  • 排查依赖冲突:暂时移除无关的第三方位置相关依赖,验证是否存在库冲突问题。

内容的提问来源于stack exchange,提问作者Everton Godoi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 17:53:10