在 Xamarin.forms 中检测到目标依赖项的循环

Cycle in target dependencies detected in Xamarin.forms

我在构建使用 Xamarin.forms 构建的 Android 项目时遇到此错误。

这是在我安装 Xam.Plugin.Media 包后发生的,我无法将它放回去。

谁能帮帮我?提前谢谢你。

Error: Error building target _XamarinAndroidBuildAarProguardConfigs: Microsoft.Build.BuildEngine.InvalidProjectFileException: Cycle in target dependencies detected at Microsoft.Build.BuildEngine.Target.BuildOtherTargets (System.Collections.Generic.IEnumerable1[T] targetNames, System.Action1[T] missing_target, System.Boolean& executeOnErrors) [0x00065] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs:263

  at Microsoft.Build.BuildEngine.Target.BuildDependencies (System.Boolean& executeOnErrors) [0x0003f] in

/private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs:211

  at Microsoft.Build.BuildEngine.Target.BuildActual (System.String built_targets_key, System.Boolean& executeOnErrors) [0x00091] in

/private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs:177 (Transportesbr.Droid)

下面是Android项目中的包信息。

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CarouselView.FormsPlugin" version="4.4.2" targetFramework="monoandroid71" />
  <package id="Plugin.CurrentActivity" version="1.0.1" targetFramework="monoandroid71" />
  <package id="Plugin.Permissions" version="2.0.1" targetFramework="monoandroid71" />
  <package id="Xam.Plugin.Media" version="3.0.1" targetFramework="monoandroid71" />
  <package id="Xam.Plugins.Forms.ImageCircle" version="1.8.1" targetFramework="monoandroid71" />
  <package id="Xam.Plugins.Forms.RoundedBoxView" version="1.0.0.7" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Annotations" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Compat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.UI" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.Utils" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Design" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Fragment" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Media.Compat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Transition" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v4" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.CardView" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.Palette" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Build.Download" version="0.4.5" targetFramework="monoandroid71" />
  <package id="Xamarin.Forms" version="2.3.4.247" targetFramework="monoandroid71" />
  <package id="XFControls" version="1.0.0.6" targetFramework="monoandroid71" developmentDependency="true" />
</packages>

我尝试了以下步骤并且有效。

  1. 更新了所有软件包,包括 Android 中的 Xam.plugin.media 要更新的项目 package.config.

  2. 已将代码推送到 GitHub。当然,我有一个通用的 .gitignore 文件和包文件在提交时被忽略。

  3. 在新位置再次提取代码并重新安装软件包。 又得到了运行!

我们可以创建一个新项目并复制代码,但我的项目文件太多,使用 Github 比创建新项目快得多。 希望这有帮助。

将软件包 Xamarin.Build.Download 从版本 0.4.6 降级到 0.4.5

如何降级 Nuget - https://kb.xamarin.com/customer/en/portal/articles/2378153-how-do-i-downgrade-a-nuget-package-