Xamarin Method 'Plugin.Geolocator.Abstractions.IGeolocator.Getpositionasync' not found

Asked

Viewed 168 times

0

You’re making a mistake for me:

"Method 'Plugin.Geolocator.Abstractions.IGeolocator.Getpositionasync' not found"

In IOS version is working well, but on Android could someone give me a hint? It’s my first app in Xamarin

using Xamarin.Forms;
using Plugin.Geolocator;
using System.Threading.Tasks;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;

namespace LocationSampleApp
{
    public partial class LocationSampleAppPage : ContentPage
    {
        public LocationSampleAppPage()
        {
            InitializeComponent();
            btnTeste.Clicked += BtnGetLocation_Clicked;
        }

        public async void BtnGetLocation_Clicked(object sender, EventArgs e)
        {
            await RetreiveLocation();
        }

        private async Task RetreiveLocation()
        {
            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;

            if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled)
            {
                var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(100));
                if (position == null)
                    return;

                txtLang.Text = "Latitude " + position.Latitude.ToString();
                txtLong.Text = "Longitude " + position.Longitude.ToString();
            }
            else{
                await DisplayAlert("Error", "Home", "OK");
            }
        }
    }
}

inserir a descrição da imagem aqui

  • Voce included the library in the android project?

  • make sure how much work with some library, the same should be installed in all projects (Portable, iOS, Android and UWP).

  • yes it is installed, in the project Locationsampleapp.Droid -> "Packeges" Xam.Plugin.Geolocator has to install and somewhere else ?

  • Do this, delete the BINS and OBJ folders of all projects then do a package store! the Xamarin is full of these details, sometimes I always need to do this when I go through this kind of problem!

  • function :D.. deletes the BINS and OBJ folders of all projects then makes a packet Restore!

1 answer

0


Delete the BIN and OBJ folders of all projects and then do a RESTORE of the packages! Xamarin has a lot of these little details! ;) I hope I have helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.