Bug 39870 - Xamarin.Forms.Maps Geocoder GetPositionsForAddressAsync always returns an empty set on Android
Summary: Xamarin.Forms.Maps Geocoder GetPositionsForAddressAsync always returns an emp...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.1.0
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-23 18:33 UTC by Lynn Koehler
Modified: 2017-12-06 14:24 UTC (History)
10 users (show)

Tags: ac, maps, android
Is this bug a regression?: ---
Last known good build:


Attachments
WorkingWithMaps sample XF.Maps 2.1.0.6529/X.GPS.Base,Maps 26 (3.71 MB, application/x-zip-compressed)
2016-03-23 18:33 UTC, Lynn Koehler
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 39870 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Lynn Koehler 2016-03-23 18:33:48 UTC
Created attachment 15506 [details]
WorkingWithMaps sample XF.Maps 2.1.0.6529/X.GPS.Base,Maps 26

Xamarin.Forms.Maps Geocoder.GetPositionsForAddressAsync always returns an empty list of positions on Android. 

There is no error or hang, just no data returned. 
The behavior is the same on Xamarin Android Player, Google AVD, and Android devices.
The method returns proper data on iOS. 
The reverse geocode method GetAddressesForPositionAsync works properly on Android as well as iOS.

The problem can be reproduced using the Xamarin Forms sample WorkingWithMaps, Geocode page. 
Click the Geocode button, no results are shown. 
Click the Reverse Geocode button, results are displayed.

I downloaded the WorkingWithMaps sample, built it, and the Geocoder GetPositionsforAddressAsync returned no positions. 

I updated Xamarin.Forms and Xamarin.Forms.Maps to 2.1.0.6529 (and Xamarin.GooglePlayServices.Base and .Maps to the required level 26). I changed the Package and the API_KEY to my development name and key in the Android Manifest. No change - no positions returned from the Geocoder with Android.

I've attached the WorkingWithMaps (I changed the Package and API_KEY back to the sample data) after I updated Xamarin.Forms and Xamarin.Forms.Maps.
Comment 1 Rui Marinho 2016-03-24 18:30:20 UTC
After looking at it better, if i remove 394 from the xamarinAddress variable it works just fines, seems something changed in the Android api but is not related with Xamarin.Forms

If you use:

>var xamarinAddress = "Pacific Ave, San Francisco, California";

it will return results.
Comment 2 Lynn Koehler 2016-03-25 14:48:20 UTC
Our company has a Xamarin app (based on Xamarin.Forms and Xamarin.Forms.Maps) that provides a map based on a street address and A pin is dropped at the first location returned by the Geocoder.GetPositionsForAddressAsync method (a method in Xamarin.Forms.Map library.

Removing the number from the street address reduces the accuracy of the pin location so much as to appear inaccurate. Using the Xamarin San Francisco address used in the WorkingWithMaps app without the street address number places the pin far to the west of the target address - in the Pacific Heights neighborhood instead of a more accurate pin placement provided by geocoding with the street number in the address.

If there has been a change in the Android API causing a street address with the number to return no results - I would hope that Xamarin would modify the Xamarin.Forms.Maps.Geocoder method to deal with that change.

Is it the Xamarin solution to this problem that we (developers) accept a far less accurate geocoding result from the Xamarin.Forms.Maps.Geocoding method by excluding the street number from addresses - that imprecise geocoding is better than zero results?
Comment 3 Lynn Koehler 2016-04-28 02:57:28 UTC
Updated a copy of the attached WorkingWithMaps to Xamarin.Forms and Xamarin.Forms.Maps 2.2 and the problem persists as documented.
Comment 4 christine.blanda 2016-08-29 15:20:24 UTC
Any update on this?
Comment 5 man_xam 2016-10-17 19:05:23 UTC
I am having this issue.
Comment 6 Alexandre TEIXEIRA 2017-08-26 14:45:56 UTC
For me the both Goecoding methods retrieve nothing.

1. GetAddressesForPositionAsync return nothing ( never go to next step )
2. GetPositionsForAddressAsync throw a GRPC error.


[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.IO.IOException: grpc failed
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <6cd960837cc24c26bab2a0a29b597627>:0 
[MonoDroid]   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00014] in <6cd960837cc24c26bab2a0a29b597627>:0 
[MonoDroid]   at Android.Locations.Geocoder.GetFromLocationName (System.String locationName, System.Int32 maxResults) [0x0003c] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at Android.Locations.Geocoder+<>c__DisplayClass17_0.<GetFromLocationNameAsync>b__0 () [0x00000] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at Xamarin.Forms.Maps.Android.GeocoderBackend+<GetPositionsForAddressAsync>d__1.MoveNext () [0x0006b] in <39c694c022be4f7b8a39897d372b2d00>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at Picaplant.Views.GeolocationPage+<HandleAdressCompleted>d__8.MoveNext () [0x00047] in /Users/OrcusZ/Documents/AutoEntrepreneur/Picaplant/Source/Picaplant/Views/GeolocationPage.xaml.cs:158 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MonoDroid]   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at (wrapper dynamic-method) System.Object:6621ff63-14b8-4291-a222-45bff630bddc (intptr,intptr)
[MonoDroid]   --- End of managed Java.IO.IOException stack trace ---
[MonoDroid] java.io.IOException: grpc failed
[MonoDroid]     at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
[MonoDroid]
Comment 7 FieldstrikeMobile 2017-10-24 08:31:33 UTC
I am seeing the GRPC error using JamesMontemagno GeoCoder on Android.

Anyone know a solution for this?
Comment 8 Brent 2017-12-04 23:21:07 UTC
So I'm hitting this issue as well.  The Geocoder GetPositionsForAddressAsync returns no data when called on Android emulator, even on the demo project provided.  This bug has been listed for over a year and half and confirmed, yet I and many others have spent hours having to find the work around to debug on real device instead of emulator.  

Can't this be fixed?

Brent
Comment 9 Lynn Koehler 2017-12-06 14:24:49 UTC
Update: In the summer of 2016, our dev group replaced the use of the Xamarin.Forms.Maps geocoding method with the Google Maps API geocoder. We continue to use Xamarin.Forms.Maps for the rest of our mapping needs.

If marker placement precision is not required for your app, Rui Marinho's suggestion above about removing the street number from the address does work - the geocoder returned data in our testing. In the case of the demo project data, however, the precision was off by about 2 miles for the Xamarin office.