GRPC failed error during various method calls
🐛 Bug Report
Hello, we sometimes run to the following problem using Geolocator. Method that throws error varies. This time, we managed to get some information during placemarkFromCoordinates call.
Error object
Error type: PlatformException Error message: PlatformException(ERROR_GEOCODING_COORDINATES, grpc failed, null)
Device info:
Internet: wifi version.securityPatch: 2018-12-01 version.sdkInt: 27 version.release: 8.1.0 version.previewSdkInt: 0 version.incremental: G390FXXU3BRL3 version.codename: REL version.baseOS: board: universal7570 bootloader: G390FXXU3BRL3 brand: samsung device: xcover4lte display: M1AJQ.G390FXXU3BRL3 hardware: samsungexynos7570 host: SWDH7002 id: M1AJQ manufacturer: samsung model: SM-G390F product: xcover4ltexx supported32BitAbis: [armeabi-v7a, armeabi] supported64BitAbis: [] supportedAbis: [armeabi-v7a, armeabi] tags: release-keys type: user isPhysicalDevice: true
Permission info:
calendar: unknown camera: granted contacts: unknown location: granted microphone: granted phone: granted photos: granted reminders: granted sensors: unknown sms: unknown storage: granted speech: granted locationAlways: granted locationWhenInUse: granted mediaLibrary: granted
Memory info:
Total physical memory: 1839 MB Free physical memory: 35 MB Total virtual memory: 3375 MB Free virtual memory: 1184 MB
StackTrace
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292)
<asynchronous suspension>
#2 Geolocator.placemarkFromCoordinates (package:geolocator/geolocator.dart:251)
<asynchronous suspension>
Additional googling of error message showed this SO question pointing to two google bug reports (64418751, 64247769). Looks like there is problem with internal geolocation routines.
Expected behavior
Although this problem is caused by another problem in underlying structure, geolocator should not crash but should either
- throw own specific exception that could be handled in consuming code as PlatformException is pretty general
- or return null
Great alternative would be optional possibility to use Geocoding API web service
Reproduction steps
There is no clear reproduction manual. Only way we can experience it is by daily use of plugin. Sometimes it happens sometimes not.
Configuration
Version: 3.0.1
Platform:
- [ ] :iphone: iOS
- [x] :robot: Android
I think I'm facing a similar issue both on iOS and Android. In my application I'm requesting for a new placemark every time google maps camera moves, because I need to update the address displayed to the user. But after a few calls to placemarkFromCoordinates the geolocator plugin stops working, always returning the following error: PlatformException(ERROR_REVERSEGEOCODING_LOCATION, The operation couldn’t be completed.
I have same issue. It is working correcltly on emulators but not on real device.
i have also same issue both on ios and android
@prasant10050 I can give you a workaround with Javascript API calls. That's how I am using currently.
please fix this asap because i have already integrated this package into my production app.
@prasant10050 I can give you a workaround with Javascript API calls. That's how I am using currently.
Can you please add some more details about that workaround?
Hello developers, I have been facing the same problem, but I think I do know what is happening here. I was getting PlatformException : ERROR_GEOCODING_COORDINATES, grpc failed, null every time I use geolocator.
I tried to change my ip address. I connect my phone to a vpn with USA ip address, and boom !! geocoder now is working..
I think this has something to do with where you live... some google api services not available in some countries, so you need to connect through proxy or vpn to get them..
hope this help. Thank you..
i'm using Google DNS (8.8.8.8) and it seems to be working good (I live in Brazil)
I also got same problem, kindly check. Thanks!
This generally seems to be an issue when calling some web API. I used this library from inside my companies network on an emulator and it failed. I ran the same code with the laptop connected to some other wifi that doesn't go through my companies proxy and the result came in almost instantly.
I also have issue with grpc failed. When turn off network and turn it on again then it almost always shows this error. Please fix this bug.
This issue depends on the location of the user itself. If your country doesn't support the connection to the Google Play Services, you can't establish a connection. As @ramioooz says, a VPN could help to establish a connection with the Google Play Services.
@StijnWoerkom Nice info. Although that may not be all the cases. In my original report I have stated that it happens only sometimes. @sokolej79 might have point with his network turning on and off as it may happen in cases when internet connection is temporary unavailable. Good application should handle this.
As I have proposed throwing new exception type would be great. Catching not very specific PlatformException may introduce hidden bugs where developers may also catch other PlatformExceptions they would want to handle differently.
Also, that exception message / or doccomments may also point developers that use this plugin to documentation link explaining issue with Google Play Services.
@MartinHlavna Thank you for your reply. We are always open-minded about introducing new methods of handling PlatformException. If you have thoughts about this subject you are always welcome to contribute to the plugin. I am still working on the documentation to explaining this issue about Google Play Services.
From @StijnWoerkom: "sokolej79 might have point with his network turning on and off as it may happen in cases when internet connection is temporary unavailable. Good application should handle this." I use connectivity plugin and when turn off/on I dont allow user to get location again before network is turned on again. Dialog error block untill network is on again.
This error does not happens allways on same conditions. Only occasionally. Sometimes error happens only once other times when network is again and try multiple times to get location again error happens multiple times untill i restart the app.
@prasant10050 I can give you a workaround with Javascript API calls. That's how I am using currently.
Please share with us
I did not receive an error when I changed or reinstalled the emulator or uninstall the app and try installing it again.
Do we always have to use VPN?
facing same issue.
E/flutter (18757): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(ERROR_GEOCODING_COORDINATES, grpc failed, null)
E/flutter (18757): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (18757): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (18757):