So sorry if this is really simple (also failing to install google play services on Marshmallow emulator, and getting a tad wound up!).
I am aiming to get GPS data in a Xamarin Android C# project on Visual Studio 2017 (15.6.3).
I am following the Xamarin Location Services walkthrough (https://docs.microsoft.com/en-gb/xamarin/android/platform/maps-and-location/location#using-the-fused-location-provider) and source code examples. I have tried targeting Android 6.0 (my preferred) and also 7.1 and MonoAndroid6 and MonoAndroid71, respectively.
I have definitely installed the NuGet packages for Xamarin.GooglePlayService.Location, .Maps and the required 'base' libraries (.Base, .Basement and .Tasks) - versions 32.961.0 and 42.1021.1 (target dependant).
The following code tells me "The type or namespace name 'FusedLocationProviderClient' could not be found (are you missing a using directive or an assembly reference?"
private FusedLocationProviderClient fusedLocationProviderClient;
I have used Object Browser to explore the libraries, and do not even see FusedLocationProviderClient (just FusedLocationProviderApi - which I also read on SO is deprecated...).
Should I be using the 'older' Location Service APIs to target 6.0, or am I missing something else?
Many thanks.
Just add the NuGet package Xamarin.GooglePlayServices.Location
There are three APIs levels involved in a
Xamarin.Android
project, one is Xamarin specific, that is the oneTarget Framework
, not to be confused with theTarget Android Version
that sets thetargetSdkVersion
in the app's Manifest.Set your
Target Framework
to the latest and greatest (currently 8.1), theTarget Android Version
to6.0
and (re-)install your packages.Understanding Android API Levels : https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels?tabs=vswin