首页 > 解决方案 > 如何修复 Xamarin Forms 空白项目构建错误

问题描述

我在新的 Xamarin 空白项目中有一些错误。

我试过了:

项目首次构建失败,出现以下错误:


Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.CustomTabs, referenced by Xamarin.Essentials. Please add a NuGet package or assembly reference for Xamarin.Android.Support.CustomTabs, or remove the reference to Xamarin.Essentials. TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.Compat, referenced by Xamarin.Android.Support.DrawerLayout. Please add a NuGet package or assembly reference for Xamarin.Android.Support.Compat, or remove the reference to Xamarin.Android.Support.DrawerLayout.    TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   The “Xamarin.Android.Support.BuildTasks.VerifyVersionsTask” task could not be loaded from the assembly…nuget\packages\xamarin.android.support.annotations\28.0.0.1\build\monoandroid90\Xamarin.Android.Support.BuildTasks.dll. Could not load file or assembly ‘…nuget\packages\xamarin.android.support.annotations\28.0.0.1\build\monoandroid90\Xamarin.Android.Support.BuildTasks.dll’ or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.   TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.Compat, referenced by Xamarin.Android.Support.CoordinaterLayout. Please add a NuGet package or assembly reference for Xamarin.Android.Support.Compat, or remove the reference to Xamarin.Android.Support.CoordinaterLayout.  TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.Compat, referenced by Xamarin.Android.Support.SlidingPaneLayout. Please add a NuGet package or assembly reference for Xamarin.Android.Support.Compat, or remove the reference to Xamarin.Android.Support.SlidingPaneLayout.  TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Arch.Lifecycle.Common, referenced by Xamarin.Android.Arch.Lifecycle.LiveData.Core. Please add a NuGet package or assembly reference for Xamarin.Android.Arch.Lifecycle.Common, or remove the reference to Xamarin.Android.Arch.Lifecycle.LiveData.Core.  TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Arch.Core.Common, referenced by Xamarin.Android.Arch.Lifecycle.LiveData. Please add a NuGet package or assembly reference for Xamarin.Android.Arch.Core.Common, or remove the reference to Xamarin.Android.Arch.Lifecycle.LiveData.  TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.Compat, referenced by Xamarin.Android.Support.SwipeRefreshLayout. Please add a NuGet package or assembly reference for Xamarin.Android.Support.Compat, or remove the reference to Xamarin.Android.Support.SwipeRefreshLayout.    TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.Compat, referenced by Xamarin.Android.Support.CustomView. Please add a NuGet package or assembly reference for Xamarin.Android.Support.Compat, or remove the reference to Xamarin.Android.Support.CustomView.    TestAPP.Android

Severity    Code    Description Project File    Line    Suppression State
Error   Can not resolve reference: Xamarin.Android.Support.v7.RecyclerView, referenced by Xamarin.Forms.Platform.Android. Please add a NuGet package or assembly reference for Xamarin.Android.Support.v7.RecyclerView, or remove the reference to Xamarin.Forms.Platform.Android.  TestAPP.Android

标签: xamarinxamarin.forms

解决方案


请尝试以下

  1. 升级 Xamarin.Forms 解决方案中所有项目的所有 Xamarin.Forms 和 Xamarin.Essentials nuget 包

  2. 关闭 Visual Studio

  3. 进入您的 Android 项目的 .csproj 文件并将所有 Xamarin.Android 支持 nuget 包(可能类似于 v27.xxx)的版本号更改为最新版本,即 v28.0.0.1(只需全部替换即可更新到那个版本)

  4. 从每个项目文件夹中删除 bin 和 obj 文件夹

  5. 在 Visual Studio 中重新打开解决方案,进行清理并重新构建


推荐阅读