使用 NuGet 安装 GooglePlayServices 时出现安装包错误

Installing GooglePlayServices with NuGet gives me a Install-Package error

所以我正在尝试将这个 package 安装到我的解决方案中,但我遇到了一个奇怪的错误,我似乎无法修复或找到解决方案。

Install failed. Rolling back... Install-Package : Could not install package 'Xamarin.Android.Support.v7.AppCompat 21.0.3.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.2', but the pack age does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:1 char:16 + Install-Package <<<< Xamarin.GooglePlayServices + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

我已经尝试将我的目标 MonoAndroid 版本更改为最新或最早的版本,但似乎没有任何改变,所以我已将其恢复到原来的位置。

这是我遇到的错误。问题是我要么需要让它工作(因为 Xamarin 没有更新他们的网站,所以我不能从那里下载它,只能使用他们的 .dll)或者自己为 Google Play Services 进行绑定可能会很痛苦。

除非有别的办法? 提前致谢!

查看 Xamarin.Android.Support.v7.AppCompat 21.0.3.0 NuGet 包,它仅包含一个用于 MonoAndroid 4.0.3 的程序集,因此您的项目需要以该版本或更高版本为目标然后才能安装它。

看起来您正在使用 Visual Studio,因此您可以进入项目选项并更改项目属性中的目标 Android 版本,然后使用 Compile Android 版本 或编辑项目文件 (.csproj) 并直接在文件中更改 TargetFrameworkVersion。

<TargetFrameworkVersion>v4.3</TargetFrameworkVersion>

如果您需要以 Android 2.2 为目标,那么您可以使用 Xamarin.GooglePlayServicesFroyo NuGet 包,因为它可以安装到以 MonoAndroid 2.2

为目标的项目中

以下设置适合我:

关注this answer,你要做的就是改变这个:

对此: