android - 预期类( 'com.google.android.gms.location.FusedLocationProviderClient' 的声明)在 native react 中

标签 android reactjs react-native expo native

这之前工作正常。 可能未处理的 promise 拒绝(id:0): 错误:调用 native 方法时遇到异常:在模块 ExpoLocation 上执行导出方法 getLastKnownPositionAsync 时发生异常:找到接口(interface) com.google.android.gms.location.FusedLocationProviderClient,但需要类('com.google.android.gms 的声明.location.FusedLocationProviderClient'

我已将以下内容添加到我的 build.gradle 文件中:

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

package.json 文件:

{
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "appcenter": "4.4.5",
    "appcenter-analytics": "4.4.5",
    "appcenter-crashes": "4.4.5",
    "expo": "~41.0.1",
    "expo-location": "~12.0.4",
    "expo-splash-screen": "~0.10.2",
    "expo-status-bar": "~1.0.4",
    "expo-updates": "~0.5.4",
    "jwt-decode": "^2.2.0",
    "lottie-react-native": "^5.0.1",
    "radio-buttons-react-native": "^1.0.4",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "~0.63.4",
    "react-native-cli": "^2.0.1",
    "react-native-code-push": "^7.0.5",
    "react-native-elements": "^3.4.1",
    "react-native-fast-image": "^8.5.11",
    "react-native-geo-fencing": "^0.1.0",
    "react-native-geocoding": "^0.5.0",
    "react-native-geolocation-service": "^5.3.0-beta.3",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-places-autocomplete": "^2.2.0",
    "react-native-looped-carousel": "^0.1.13",
    "react-native-maps": "0.27.1",
    "react-native-push-notification": "^8.1.1",
    "react-native-razorpay": "^2.2.9",
    "react-native-reanimated": "^2.1.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "^3.1.1",
    "react-native-secure-storage": "^0.1.2",
    "react-native-share": "^7.2.1",
    "react-native-simple-toast": "^1.1.3",
    "react-native-svg": "^12.3.0",
    "react-native-unimodules": "~0.13.3",
    "react-native-version-check": "^3.4.3",
    "react-native-web": "~0.13.12",
    "react-native-webp-format": "^1.1.2",
    "react-navigation": "^4.4.4",
    "react-navigation-drawer": "^2.7.1",
    "react-navigation-stack": "^2.10.4",
    "react-navigation-tabs": "^2.11.2",
    "rn-fetch-blob": "^0.12.0"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0"
  },
  "private": true,
  "name": "test",
  "version": "1.0.0"
}

最佳答案

此问题源于 google play 服务在最新版本中更新了一些内容。 https://developers.google.com/android/guides/releases#october_13_2022

我能够通过在 android/build.gradle 文件中将我的 google play 服务版本锁定为 20.0.0 来解决这个问题。我们之前使用的是“+”。 See image here for the change .

关于android - 预期类( 'com.google.android.gms.location.FusedLocationProviderClient' 的声明)在 native react 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74085319/

相关文章:

javascript - React-native- 如果数组为空,则有条件地禁用 TouchableHighlight

javascript - 如何观察 react-native node_modules 的变化

android - 应用在元数据中包含对 Android 的引用

c# - 为 RESTful 服务格式化 DateTime 的最佳方式?

android - TableLayout 放置在 ScrollView 内时被截断

javascript - react : How to avoid multiple function call

javascript - 如何使用 React、fetch 和 Django REST 上传图片

android - 如何将共享首选项值设置为布局

android - INSTALL_FAILED_TEST_ONLY 在 Android Studio 2.4 预览版 7

reactjs - React hooks 使用 eslint-plugin-react-hooks@next 附加不需要的值