我正在尝试使用Xamarin.Essentials包,但我得到了一个例外
例外情况:此功能未在此程序集的可移植版本中实现。您应该从您的主要应用程序项目中引用nuget包,以便引用特定于平台的实现。在xamarin.essentials.geolocation.platformlocationasync“,我在每个平台上安装了这个软件包
这是我的代码:
private async void Button_Clicked(object sender, EventArgs e)
{
try
{
var request = new GeolocationRequest(GeolocationAccuracy.Medium);
var location = await Geolocation.GetLocationAsync(request);
if (location != null)
{
latitude.Text = location.Latitude.ToString();
longitude.Text = location.Longitude.ToString();
}
}
catch (FeatureNotEnabledException fnex)
{
}
catch (PermissionException perex)
{
}
catch (Exception ex)
{
await DisplayAlert("Error3", ex.ToString(), "ok");
}
}发布于 2019-04-08 14:47:12
根据本期报告:https://github.com/xamarin/Essentials/issues/379
您需要将编译目标版本设置为Android8.1
发布于 2019-04-08 14:53:56
截至2019年3月,任何针对低于API-26(8.1)的Android版本的应用程序都不会被Play商店接受(上述例外的原因也是如此),所以我建议你更新一下。
此外,您的设备范围符合标准,因此这不是问题(见下文),
Xamarin.Essentials主要关注以下平台:
https://stackoverflow.com/questions/55574028
复制相似问题