FusedLocationProviderClient - 找不到类型或命名空间(错误) [英] FusedLocationProviderClient - type or namespace could not be found (error)

查看:47
本文介绍了FusedLocationProviderClient - 找不到类型或命名空间(错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这真的很简单(也未能在 Marshmallow 模拟器上安装 google play 服务,并且有点麻烦!).

So sorry if this is really simple (also failing to install google play services on Marshmallow emulator, and getting a tad wound up!).

我的目标是在 Visual Studio 2017 (15.6.3) 上的 Xamarin Android C# 项目中获取 GPS 数据.

I am aiming to get GPS data in a Xamarin Android C# project on Visual Studio 2017 (15.6.3).

我正在关注 Xamarin 位置服务演练 (https://docs.microsoft.com/en-gb/xamarin/android/platform/maps-and-location/location#using-the-fused-location-provider) 和源代码示例.我曾尝试分别针对 Android 6.0(我的首选)以及 7.1、MonoAndroid6 和 MonoAndroid71.

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.

我确实为 Xamarin.GooglePlayService.Location、.Maps 和所需的基本"库(.Base、.Basement 和 .Tasks)安装了 NuGet 包 - 版本 32.961.0 和 42.1021.1(依赖于目标).

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).

以下代码告诉我找不到类型或命名空间名称‘FusedLocationProviderClient’(您是否缺少 using 指令或程序集引用?"

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;

我已经使用对象浏览器来探索这些库,甚至没有看到 FusedLocationProviderClient(只是 FusedLocationProviderApi - 我也在 SO 上阅读过它已被弃用......).

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...).

我应该使用较旧的"定位服务 API 来定位 6.0,还是我遗漏了其他东西?

Should I be using the 'older' Location Service APIs to target 6.0, or am I missing something else?

非常感谢.

推荐答案

Xamarin.Android 项目涉及三个 API 级别,一个是 Xamarin 特定的,也就是一个 Target框架不要与在应用的清单中设置targetSdkVersionTarget Android Version混淆.

There are three APIs levels involved in a Xamarin.Android project, one is Xamarin specific, that is the one Target Framework, not to be confused with the Target Android Version that sets the targetSdkVersion in the app's Manifest.

Target Framework – 指定在构建应用程序时使用的框架.此 API 级别由 Xamarin.Android 在编译时使用.

Target Framework – Specifies which framework to use in building your application. This API level is used at compile time by Xamarin.Android.

Minimum Android Version – 指定您希望应用支持的最旧 Android 版本.Android 在运行时使用此 API 级别.

Minimum Android Version – Specifies the oldest Android version that you want your app to support. This API level is used at run time by Android.

Target Android Version – 指定您的应用要运行的 Android 版本.Android 在运行时使用此 API 级别.

Target Android Version – Specifies the version of Android that your app is intended to run on. This API level is used at run time by Android.

将您的 Target Framework 设置为最新和最好的(当前为 8.1),将 Target Android 版本 设置为 6.0 并(重新)安装你的包裹.

Set your Target Framework to the latest and greatest (currently 8.1), the Target Android Version to 6.0 and (re-)install your packages.

了解 Android API 级别:https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels?tabs=vswin

Understanding Android API Levels : https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels?tabs=vswin

这篇关于FusedLocationProviderClient - 找不到类型或命名空间(错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆