android - Xamarin/Visual Studio Mac 空白表单项目错误

标签 android macos visual-studio xamarin android-appcompat

我完全知道有人问过(并回答过)类似的问题,但是,我的具体情况没有任何效果。尝试创建新的 Xamarin Forms 空白项目时,Visual Studio for Mac 中会出现此问题。项目一创建就已经出现错误:

Could not install package 'Xamarin.Android.Support.v4 23.3.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.3', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

从我阅读的解决方案中,人们说我必须具有相同的目标 Android/API 和目标框架版本。我尝试了几个版本的 android,但是 VS 不允许我编辑目标框架: enter image description here

我已经将目标 Android 版本设置为 Android 7.1 (API 25) enter image description here

另外Xamarin Droid项目下的packages文件夹好像是空的,所以我尝试安装需要的NuGet包

Xamarin.Android.Support.v7.AppCompat

同样的错误发生了。这令人沮丧,因为我什至无法开箱即用地开始开发或测试我的代码 Xamarin/VS 有问题。

如果有人知道如何提供帮助,请非常具体,网上的其他内容都非常模糊,“需要更新 Xamarin.Forms”或没有太多细节或程序解释的内容。我知道许多其他人在 MacOS 上遇到与 VS/Xamarin 类似的问题。这是我的包结构: enter image description here

提前致谢。

最佳答案

我也遇到过这个问题。

根本原因是我的用户无法访问 Android SDK,因此没有目标平台可供选择,也没有安装 nuget 包。

我最终做了以下事情:

  • 使用所有默认设置安装 Android Studio,并使用 Android Studio SDK 管理器安装几个 Android SDK 级别。
  • 从 Android Studio 获取 SDK 路径并将其粘贴到 Visual Studio 中的 Preferences/SDK Locations。
  • 重新启动 Visual Studio 并创建一个新项目 - 这次它将安装一些 nuget 包。
  • 打开 Android 项目的选项,然后在 Android Application 下选择合适的最低和目标 Android 版本。

项目现在应该构建。

关于android - Xamarin/Visual Studio Mac 空白表单项目错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45020897/

相关文章:

java - 错误没有找到处理 Intent act=android.media.action.IMAGE_CAPTURE 的 Activity

android - Android TextView 的 autoLink ="all"功能

macos - 无法在 Mac OS 10.8 中从终端使用 svn 命令

macos - macosx 上的 fuse4x sshfs 执行错误

macos - NSWindow 标题栏自定义

c# - CS0433 : Ambiguous Reference System.Net.Http.HttpRequestMessageExtensions

visual-studio - Visual Studio 2017 使用旧的 Nuget 包而不是程序集引用

android - 如何在android中启用后台数据设置?

android - SurfaceTexture 是否在 Activity 暂停/恢复周期中幸存下来?

c# - 有没有一种方法可以使用 Resharper 在 Visual Studio 中显示枚举的数值?