安装 Microsoft.Azure.Mobile.Client NuGet 包后生成错误

Build error after installing Microsoft.Azure.Mobile.Client NuGet package

我在 Visual Studio 2017 年创建了一个全新的 Xamarin.Android 项目。我立即构建解决方案并将其部署到 Android 模拟器,一切正常。

然后我安装了 Microsoft.Azure.Mobile.Client v4.0.2 Nuget 包,当我尝试构建解决方案时,我现在收到以下错误:

java.lang.IllegalArgumentException: already added : Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;

输出 window 包含以下内容:

1>------ 全部开始重建:项目:TestAzure3,配置:调试任何 CPU ------ 1> TestAzure3 -> D:\Visual Studio 2017 Projects\TestAzure3\TestAzure3\bin\Debug\TestAzure3.dll 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.ViewPager+IOnPageChangeListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.ViewPager+IOnPageChangeListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.ViewPager.IOnPageChangeListenerImplementor' 的引用将引用 'Android.Support.V4.View.ViewPager+IOnPageChangeListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Widget.NestedScrollView+IOnScrollChangeListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Widget.NestedScrollView+IOnScrollChangeListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Widget.NestedScrollView.IOnScrollChangeListenerImplementor' 的引用将引用 'Android.Support.V4.Widget.NestedScrollView+IOnScrollChangeListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Widget.SwipeRefreshLayout+IOnRefreshListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Widget.SwipeRefreshLayout+IOnRefreshListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Widget.SwipeRefreshLayout.IOnRefreshListenerImplementor' 的引用将引用 'Android.Support.V4.Widget.SwipeRefreshLayout+IOnRefreshListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.App.FragmentManager+IOnBackStackChangedListenerImplementor, Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.App.FragmentManager+IOnBackStackChangedListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.App.FragmentManager.IOnBackStackChangedListenerImplementor' 的引用将引用 'Android.Support.V4.App.FragmentManager+IOnBackStackChangedListenerImplementor, Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Content.Loader+IOnLoadCanceledListenerImplementor, Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Content.Loader+IOnLoadCanceledListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Content.Loader.IOnLoadCanceledListenerImplementor' 的引用将引用 'Android.Support.V4.Content.Loader+IOnLoadCanceledListenerImplementor, Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Content.Loader+IOnLoadCompleteListenerImplementor, Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Content.Loader+IOnLoadCompleteListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Content.Loader.IOnLoadCompleteListenerImplementor' 的引用将引用 'Android.Support.V4.Content.Loader+IOnLoadCompleteListenerImplementor, Xamarin.Android.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Media.Session.MediaSessionCompat.IOnActiveChangeListenerImplementor' 的引用将引用 'Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.OS.CancellationSignal+IOnCancelListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.OS.CancellationSignal+IOnCancelListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.OS.CancellationSignal.IOnCancelListenerImplementor' 的引用将引用 'Android.Support.V4.OS.CancellationSignal+IOnCancelListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.ActionProvider+ISubUiVisibilityListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.ActionProvider+ISubUiVisibilityListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.ActionProvider.ISubUiVisibilityListenerImplementor' 的引用将引用 'Android.Support.V4.View.ActionProvider+ISubUiVisibilityListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.ActionProvider+IVisibilityListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.ActionProvider+IVisibilityListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.ActionProvider.IVisibilityListenerImplementor' 的引用将引用 'Android.Support.V4.View.ActionProvider+IVisibilityListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.IOnApplyWindowInsetsListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.IOnApplyWindowInsetsListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.IOnApplyWindowInsetsListenerImplementor' 的引用将引用 'Android.Support.V4.View.IOnApplyWindowInsetsListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.IViewPropertyAnimatorListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.IViewPropertyAnimatorListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.IViewPropertyAnimatorListenerImplementor' 的引用将引用 'Android.Support.V4.View.IViewPropertyAnimatorListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.IViewPropertyAnimatorUpdateListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.IViewPropertyAnimatorUpdateListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.IViewPropertyAnimatorUpdateListenerImplementor' 的引用将引用 'Android.Support.V4.View.IViewPropertyAnimatorUpdateListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.View.MenuItemCompat+IOnActionExpandListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.View.MenuItemCompat+IOnActionExpandListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.View.MenuItemCompat.IOnActionExpandListenerImplementor' 的引用将引用 'Android.Support.V4.View.MenuItemCompat+IOnActionExpandListenerImplementor, Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Widget.DrawerLayout+IDrawerListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Widget.DrawerLayout+IDrawerListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Widget.DrawerLayout.IDrawerListenerImplementor' 的引用将引用 'Android.Support.V4.Widget.DrawerLayout+IDrawerListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:发现重复的托管类型!托管类型和 Java 类型之间的映射必须是唯一的。第一种类型:'Android.Support.V4.Widget.SlidingPaneLayout+IPanelSlideListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';第二种:'Android.Support.V4.Widget.SlidingPaneLayout+IPanelSlideListenerImplementor, Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3):警告:对类型 'Android.Support.V4.Widget.SlidingPaneLayout.IPanelSlideListenerImplementor' 的引用将引用 'Android.Support.V4.Widget.SlidingPaneLayout+IPanelSlideListenerImplementor, Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'。 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityCompat; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityCompat$1; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityCompat$OnRequestPermissionsResultCallback; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityCompat$SharedElementCallback21Impl; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityManagerCompat; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/ActivityOptionsCompat; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/AppOpsManagerCompat; 1> 未捕获的翻译错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/app/BundleCompat; 1><br> 1> 意外的顶级异常: 1> java.lang.RuntimeException: 翻译已中断 1> 在 com.android.dx.command.dexer.Main.processAllFiles(Main.java:613) 1> 在 com.android.dx.command.dexer.Main.runMonoDex(Main.java:311) 1> 在 com.android.dx.command.dexer.Main.run(Main.java:277) 1> 在 com.android.dx.command.dexer.Main.main(Main.java:245) 1> 在 com.android.dx.command.Main.main(Main.java:106) 1> Caused by: java.lang.InterruptedException: 错误太多 1> 在 com.android.dx.command.dexer.Main.processAllFiles(Main.java:605) 1> ... 4 更多 1>C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2521,3):错误:java.lang.IllegalArgumentException:已添加:Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; ========== 全部重建:0 次成功,1 次失败,0 次跳过 ==========

我已经尝试在程序包管理器控制台中输入以下命令,但我仍然遇到同样的问题。

Update-Package -reinstall
Update-Package

有人可以帮我解决这个问题吗?

安装 Xamain.Android.Support.v4 后安装 Microsoft.Azure.Mobile.Client nuget 包将解决此问题。