简体   繁体   English

NuGet软件包安装失败“软件包还原失败。 回滚包更改 <xamarin.android> ”

[英]NuGet package install fails “Package restore failed. Rolling back package changes for <xamarin.android>”

Installing any package fails with this error, updating packages also creates this error. 安装任何软件包都会失败,并显示此错误,更新软件包也会产生此错误。 Clearing the NuGet cache files causes this error to change to "access to the path mono.cecil.dll is denied" when trying to install "Xamarin.GooglePlayServices.Ads". 尝试安装“ Xamarin.GooglePlayServices.Ads”时,清除NuGet缓存文件会导致此错误更改为“拒绝访问mono.cecil.dll路径”。 Restarting visual studio causes the package restore error to come back. 重新启动Visual Studio会导致软件包还原错误再次出现。

  1. Versions: 版本:

  2. Xamarin.Forms Project: Xamarin.Forms项目:

    • Target framework: .NET 2.0 目标框架:.NET 2.0
  3. Xamarin.Android project: Xamarin.Android项目:

    • Minimum Android Version: 5.0 (API Level 21) 最低Android版本:5.0(API级别21)
    • Target Android Version: Use Compile Using SDK version (8.0) 目标Android版本:使用SDK版本(8.0)进行编译

Well after some trial and error I have the solution. 经过一番反复尝试后,我有了解决方案。

  1. Visual Studio: 视觉工作室:

    • Update visual studio https://pastebin.com/GkEeRqg3 Update visual studio https://pastebin.com/GkEeRqg3
      • Updates Xamarin.Forms and NuGet 更新Xamarin.Forms和NuGet
    • Repair visual studio from the "Visual Studio installer" 从“ Visual Studio安装程序”修复Visual Studio
      • This Fixes the access denied to *.dll error 这修复了拒绝访问* .dll的错误
  2. Xamarin.Android project: Xamarin.Android项目:

    • Set Target Android Version: 8.1 API 27 设置目标Android版本:8.1 API 27
      • This makes the packages the require monoandroid81 happy. 这使得需要monoandroid81的软件包感到满意。
  3. Cleaning house 打扫房子

    • Delete the folder C:\\Users\\<Your_Name>\\AppData\\Local\\Xamarin` 删除文件夹C:\\ Users \\ <您的名称> \\ AppData \\ Local \\ Xamarin`
      • Not sure if this was necessary but I am documenting anything I did so others can replicate the solution. 不知道这是否必要,但我正在记录所做的任何事情,以便其他人可以复制该解决方案。
  4. Fixing NuGet 修复NuGet

    • Right-click <Project_name>.android --> Set as startup project. 右键单击<Project_name> .android->设置为启动项目。
    • Tools --> NuGet Package Manager --> Package Manager Console 工具-> NuGet软件包管理器->软件包管理器控制台
    • In the console CLI run Update-Package -Reinstall 在控制台CLI中运行Update-Package -Reinstall

Why did this happen? 为什么会这样呢?

One way or another some of the NuGet packages used in Xamarin.Android used monoandroid81. Xamarin.Android中使用的NuGet软件包中的一种或另一种使用monoandroid81。 Even though my solution was set to use 80 some NuGet packages installed were only compatible with 81. 即使我的解决方案设置为使用80,但某些安装的NuGet软件包仅与81兼容。
This was shown in the NuGet Console. 这已在NuGet控制台中显示。 Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1)

I faced the same error when I was trying to update the libraries one by one. 当我尝试一个接一个地更新库时,我遇到了同样的错误。 Then I tried selecting all required libraries and clicked the Update button bellow the search box and it works. 然后,我尝试选择所有必需的库,然后单击搜索框下方的“ 更新”按钮,它可以正常工作。 I have to tell that these libraries had dependencies between each other. 我必须告诉这些库之间相互依赖。
Here's an example: 这是一个例子:
在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Nuget - 包还原失败。 回滚“WebApplication1”的包更改。 0 - Nuget - Package restore failed. Rolling back package changes for 'WebApplication1'. 0 Xamarin.iOS 和 Xamarin.Android 的 NuGet 包缩写是什么? - What are the NuGet package abbreviations for Xamarin.iOS and Xamarin.Android? 在 NuGet package 中包含本机库,由 Xamarin.ZE84E30B9390CDB646DB6DB2C9ABZ78 使用 - Include native library in NuGet package consumed by Xamarin.Android 运行所选生成器时出错:包还原失败。回滚“MyProject”的包更改(Asp.net 核心项目错误)) - There was an error running the selected generator: Package restore failed.Rolling back package changes for 'MyProject' (Asp.net core Project Error)) 干净的VS 2015 Enterprise + Xamarin安装:错误:项目的NuGet包还原失败 - clean VS 2015 Enterprise + Xamarin Install: error: NuGet Package restore failed for project VS 2015:C# NuGet 包还原失败。 文件或目录已损坏且无法读取 - VS 2015: C# NuGet Package restore failed. The file or directory is corrupted and unreadable 对于AppHarbor上的多个软件包,NuGet软件包还原失败 - NuGet package restore fails for several packages on AppHarbor 无法恢复 NuGet package 访问被拒绝 - Failed to restore NuGet package Access denied NuGet软件包还原问题 - NuGet Package Restore Issue 使用VSPackage安装nuget软件包 - Install nuget package with a VSPackage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM