Plugin.Geolocation v3.0.3 - The given key was not present in the dictionary.

Hello

I'm stumped why I am getting this error. The sample code from http://www.github.com/jamesmontemagno/Xamarn.Plugins works great, but when I add to my own Xamarin Forms project, as soon as I call GetPositionAsync, it throws "The given key was not present in the dictionary." Does anyone know what I am doing wrong or advice to work-around?

var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000);

Thank you

Best Answer

Answers

  • MatthewGerberMatthewGerber USMember ✭✭

    I just ran into this myself. You need to configure your Android activity appropriately. Add the following to the create, resume, and start methods of your activity:

    CrossCurrentActivity.Current.Activity = this;

    However, the plugin should have automatically added a MainApplication to your Android project that does the same thing. Either way worked for me.

Sign In or Register to comment.