Flutter-geolocator: GRPC failed error during various method calls

Created on 6 Mar 2019  路  23Comments  路  Source: Baseflow/flutter-geolocator

馃悰 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
in progress triage documentation

Most helpful comment

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鈥檛 be completed.

All 23 comments

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鈥檛 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):
E/flutter (18757): #2 Geolocator.placemarkFromCoordinates (package:geolocator/geolocator.dart:256:59)
E/flutter (18757): #3 SplashScreenState._onLookupAddressPressed (package:squash_player/ui/splashscreen/splash.dart:284:10)
E/flutter (18757): #4 SplashScreenState.initGps. (package:squash_player/ui/splashscreen/splash.dart:401:11)
E/flutter (18757): #5 State.setState (package:flutter/src/widgets/framework.dart:1148:30)
E/flutter (18757): #6 SplashScreenState.initGps (package:squash_player/ui/splashscreen/splash.dart:395:7)
E/flutter (18757): #7 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:73:64)
E/flutter (18757): #8 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (18757): #9 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18757): #10 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter (18757): #11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter (18757): #12 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter (18757): #13 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter (18757): #14 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter (18757): #15 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter (18757): #16 Geolocator.getLastKnownPosition (package:geolocator/geolocator.dart)
E/flutter (18757): #17 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:73:64)
E/flutter (18757): #18 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (18757): #19 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18757): #20 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter (18757): #21 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter (18757): #22 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter (18757): #23 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter (18757): #24 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter (18757): #25 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter (18757): #26 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
E/flutter (18757): #27 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:73:64)
E/flutter (18757): #28 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (18757): #29 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18757): #30 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter (18757): #31 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter (18757): #32 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter (18757): #33 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter (18757): #34 Future._asyncComplete. (dart:async/future_impl.dart:554:7)
E/flutter (18757): #35 _rootRun (dart:async/zone.dart:1126:13)
E/flutter (18757): #36 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (18757): #37 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (18757): #38 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23)
E/flutter (18757): #39 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter (18757): #40 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)

Facing the same issue , I have a collection in firestore and this collection has 6 documents , and trying to fetch lat, lon for each document and translate it to address , 4 of them works fine but 2 of them giving me this error , I don't know why ?
Can any one help me please ?

I restarted my Device and it worked fine , same as #259 ticket solution provided by @alnaughty

Since version 6.0.0 the geocoding features are no longer part of the geolocator plugin and moved to their own plugin which can be found here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joesnarky picture joesnarky  路  3Comments

deisold picture deisold  路  3Comments

CNogueira92 picture CNogueira92  路  3Comments

BigWillieStyle picture BigWillieStyle  路  6Comments

shrishti08 picture shrishti08  路  3Comments