This was working fine earlier.
Possible Unhandled Promise Rejection (id: 0):
Error: Encountered an exception while calling native method: Exception occurred while executing exported method getLastKnownPositionAsync on module ExpoLocation: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of ‘com.google.android.gms.location.FusedLocationProviderClient’
I have added the below to my build.gradle file:
implementation 'com.google.android.gms:play-services-location:16.0.0'
package.json file:
{
"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"
}
3
Answers
This issue stems from google play services updating a few things in the latest version. https://developers.google.com/android/guides/releases#october_13_2022
I was able to solve this issue by locking my google play services version to 20.0.0 in the
android/build.gradle
file. We were previously using ‘+’. See image here for the change.As stated by Christian Mitchell the problem is due to the google play services latest version. And the solution is to force the version used in our project.
Adding googlePlayServicesVersion = "17.+" in the project build.gradle file might fix the issue for most of people but in my case it was not enough.
Using ./gradlew app:dependencies I notices that a module (react-native-activity-recognition) was referencing gms as follow : api ‘com.google.android.gms:play-services-location:+’ and therefore the latest version was still used globally
So the final solution for me was to target this module in the app build.gradle and prevent it from embedding gms as follow :
You can follow up this link it just api ‘com.google.android.gms:play-services-location:+’ error, you will get help https://github.com/Lyokone/flutterlocation/issues/802