flutter_geocoder
flutter_geocoder copied to clipboard
PlatformException when calling Geocoder.local.findAddressesFromQuery
Hello everybody! I regularly use this plugin for building production applications; but i've recently been notified by a customer of a bug on an app, [...], below is the error shown in the console
E/flutter (12189): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(failed, Failed, null)
[38;5;244mE/flutter (12189): #0 StandardMethodCodec.decodeEnvelope[39;49m
[38;5;244mE/flutter (12189): #1 MethodChannel.invokeMethod[39;49m
E/flutter (12189): <asynchronous suspension>
[38;5;248mE/flutter (12189): #2 LocalGeocoding.findAddressesFromQuery[39;49m
E/flutter (12189): <asynchronous suspension>
[38;5;248mE/flutter (12189): #3 HomePageState.searchByLocality[39;49m
E/flutter (12189): <asynchronous suspension>
[38;5;248mE/flutter (12189): #4 HomePageState.build.<anonymous closure>.<anonymous closure>[39;49m
E/flutter (12189): <asynchronous suspension>
[38;5;244mE/flutter (12189): #5 _InkResponseState._handleTap[39;49m
[38;5;244mE/flutter (12189): #6 _InkResponseState.build.<anonymous closure>[39;49m
[38;5;244mE/flutter (12189): #7 GestureRecognizer.invokeCallback[39;49m
[38;5;244mE/flutter (12189): #8 TapGestureRecognizer._checkUp[39;49m
[38;5;244mE/flutter (12189): #9 TapGestureRecognizer.acceptGesture[39;49m
[38;5;244mE/flutter (12189): #10 GestureArenaManager.sweep[39;49m
[38;5;244mE/flutter (12189): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent[39;49m
[38;5;244mE/flutter (12189): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent[39;49m
[38;5;244mE/flutter (12189): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent[39;49m
[38;5;244mE/flutter (12189): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue[39;49m
[38;5;244mE/flutter (12189): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket[39;49m
[38;5;244mE/flutter (12189): #16 _rootRunUnary (dart:async/zone.dart:1136:13)[39;49m
[38;5;244mE/flutter (12189): #17 _CustomZone.runUnary (dart:async/zone.dart:1029:19)[39;49m
[38;5;244mE/flutter (12189): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)[39;49m
[38;5;244mE/flutter (12189): #19 _invoke1 (dart:ui/hooks.dart:250:10)[39;49m
[38;5;244mE/flutter (12189): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)[39;49m
@aloisdeniel Do you have any updates on this? We are trying to use this package on a production app and we would like to avoid using google api for this.
Unfortunately I didn't have encounterd this issue yet ...
It may be linked to the system, on what device model did this happened ?
I suppose that you checked the user permission, right ?
I'm testing this on a Pixel 2. The app has location permissions. Do I need more permissions?
The weird thing is that it worked fine earlier... But it started crashing for no reason.. I was obliged to switch to bing geocoding
I'm also using open street maps which is not ideal, but it works.
This is the error I'm getting:
Unhandled Exception: PlatformException(Error 10, kCLErrorDomain, A operação não pôde ser concluída. (kCLErrorDomain erro 10.))
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
<asynchronous suspension>
#2 LocalGeocoding.findAddressesFromCoordinates (package:geocoder/services/local.dart:13:41)
Don't know if it is related but I am querying multiple addresses at the same time, asynchonously.
I want to convert latitude and longitude to formatted address. I worked with it before and it worked nicely.But don't know why it shows me this error now.
@aloisdeniel I found how to reproduce the bug.
Using this coordinate works well : (43.184319, 5.324419) Using this throws exception : (49.822816, -0.266805)
Unhandled Exception: PlatformException(not_available, Empty, null)
Seems like it does not accept negative lat/long
I though the bug was random at first because I was receiving differents GPS lat/lon from my server. Then I notice that some works and others doesn't.
Hi! any updates on this issue? Because right-now the plugin is unusable...
Hi guys. I am encountering this error too since this afternoon. It was working totally fine until one hour ago. I am using an emulator for a Pixel 2 on Ubuntu. However I tried on my real phone (Pixel) and here no error! So I updated everything and it's working on the emulator again! Hope this help someone!
I want to convert latitude and longitude to formatted address. I worked with it before and it worked nicely.But don't know why it shows me this error now.
got the same issue, any progress?
Same error is happening in iOS when using findAddressesFromQuery
.
PlatformException(Error 8, kCLErrorDomain, The operation couldn’t be completed. (kCLErrorDomain error 8.))
This will happens only in some queries.
var address= awaitGeocoder.local.findAddressesFromQuery(desc);
How to solve this issue.
Same error is happening in iOS when using
findAddressesFromQuery
.PlatformException(Error 8, kCLErrorDomain, The operation couldn’t be completed. (kCLErrorDomain error 8.))
This will happens only in some queries.
var address= awaitGeocoder.local.findAddressesFromQuery(desc);
How to solve this issue.
I just give up, and use the other plugin amap_location, it works fine.
@aloisdeniel Any news ?
I found the issue it happening in iOS only. Because IOS using apple map not google map. The only way is use Google API for retrieving details.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input={keyword}&inputtype=textquery&fields=geometry&key={API_KEY}
I got error 10
by call Geocoder.local.findAddressesFromCoordinates
, I found this error only happen on IOS .Every app started first call will work but If you call second time immediately will get this error.This happen to my app cuz for some reason I put Geocoder.local.findAddressesFromCoordinates
in widget build function and somehow this widget rebuild immediately after first build.
Sorry for not being very active lately.
I'm not sure if all of you have the exact same issue (you got different codes, and you have different OS).
In the meantime, as a workaround you can use the Google distant api via Geocoder.google
instead of Geocoder.local
(you will need an API key). This is an equivalent solution of @fazil-augr proposal.
@g-balas Thank you for finding it! I will see if I can reproduce.
@ClassSadStranger Triggering asynchronous calls from the build method is not recommended because it can be called multiple times in a row! You should store the Future
in a StatefullWidget
instead.
Moving to https://pub.dev/packages/geolocator
geolocator has the same problem
I had the same problem while using the emulator. But while using device, I dont have any problem.
I solved the emulator problem by opening the google maps and then running the app in emulator.
hope this helps some one from stop spending a lot of time like i did.
Happened to have the same problem. In my case it was due to the fact that I was sending too many requests in a short time. The requests were sent using the "onChanged" event of a TextField.
I solved the problem by using a Timer to send one single request 1 second after the user has stopped typing.
I had the same problem while using the emulator. But while using device, I dont have any problem.
I solved the emulator problem by opening the google maps and then running the app in emulator.
hope this helps some one from stop spending a lot of time like i did.
this worked for me in an emulator aswell, weirdly
I am facing the same problem , I have a collection with list of document and each document has a field type of Geopoint , some of them work fine and translate the latitude and longitude to address , but some of them , gime me this error PlatformException(failed, Failed, null) .. and I set a value for these fields , I don't know why
I have also faced the same problem on my emulator and my physical device
I am also having the same problem but I realized that this error occurs when you are using Geocoder without internet. The problem is even if you put the code in try catch, it still raise the error
For me the first call of Geocoder.local.findAddressesFromCoordinates(coordinates); is succesful, but then stop working.
In my case i have a page with a google map that shows the address every time the user stop move the map. When I open the page the address where the map is centered is retrieved correctly, then it throws the PlatformException(failed, Failed, null) at every later call.
It's strange that when i wrote the code everything worked well, then I closed the app and the emulator, relaunched it, and this error showed up
Worked for me
Geocoder.google("APIKEY").findAddressesFromCoordinates(coordinates);
that works because it is using google's API. This issue is related to calling the Geocoder local method.
"You can alternatively use Geocoder.google member for requesting distant data from google services instead of native ones." - https://pub.dev/packages/geocoder
On Sun, Jul 19, 2020 at 11:55 AM Burak Tuntaş [email protected] wrote:
Worked for me
Geocoder.google("APIKEY").findAddressesFromCoordinates(coordinates);
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aloisdeniel/flutter_geocoder/issues/29#issuecomment-660667301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGB2YPH76MGHPCCRBCSVE4LR4MJQPANCNFSM4INARKCA .
Guys. Same Error came for me in "GeoCoder" lib in android emulator. Set the default location in emulator settings. Then it will work fine.
@stevenosse @aloisdeniel Hi guys! I have fixed it, please check https://github.com/aloisdeniel/flutter_geocoder/pull/47