flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

GRPC failed error during various method calls

Open MartinHlavna opened this issue 7 years ago • 23 comments

🐛 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

MartinHlavna avatar Mar 06 '19 13:03 MartinHlavna

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.

davicg avatar Mar 29 '19 15:03 davicg

I have same issue. It is working correcltly on emulators but not on real device.

abumoallim avatar Apr 17 '19 08:04 abumoallim

i have also same issue both on ios and android

prasant10050 avatar Apr 24 '19 12:04 prasant10050

@prasant10050 I can give you a workaround with Javascript API calls. That's how I am using currently.

abumoallim avatar Apr 24 '19 12:04 abumoallim

please fix this asap because i have already integrated this package into my production app.

prasant10050 avatar May 08 '19 16:05 prasant10050

@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?

langerkirill avatar May 13 '19 02:05 langerkirill

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..

ramioooz avatar May 27 '19 00:05 ramioooz

i'm using Google DNS (8.8.8.8) and it seems to be working good (I live in Brazil)

Fernandomr88 avatar Jul 09 '19 12:07 Fernandomr88

I also got same problem, kindly check. Thanks!

crazyfree avatar Aug 07 '19 07:08 crazyfree

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.

mvarendorff avatar Aug 08 '19 10:08 mvarendorff

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.

sokolej79 avatar Oct 11 '19 04:10 sokolej79

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 avatar Oct 11 '19 09:10 StijnWoerkom

@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 avatar Oct 11 '19 10:10 MartinHlavna

@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.

StijnWoerkom avatar Oct 11 '19 11:10 StijnWoerkom

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.

sokolej79 avatar Oct 19 '19 21:10 sokolej79

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.

sokolej79 avatar Oct 19 '19 21:10 sokolej79

@prasant10050 I can give you a workaround with Javascript API calls. That's how I am using currently.

Please share with us

SirJulian avatar Dec 06 '19 08:12 SirJulian

I did not receive an error when I changed or reinstalled the emulator or uninstall the app and try installing it again.

hasanhasanov avatar Dec 16 '19 07:12 hasanhasanov

Do we always have to use VPN?

aminnegahban73 avatar Jan 16 '20 19:01 aminnegahban73

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)

sohameasternts avatar Mar 11 '20 07:03 sohameasternts