如何修复在更新到Visual Studio 2019版本16.7.0之后出现的错误

问题描述

我有一个使用Xamarin.Forms构建的移动应用

将Visual Studio 16.4.4 更新到 16.7.0

之后

这些错误出现了

Assembly 'Xamarin.GooglePlayServices.Maps' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.CardView' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Base' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.MediaRouter' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.Vector.Drawable' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android           
Assembly 'Xamarin.Android.Support.Design' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Gcm' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.AppCompat' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.RecyclerView' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Basement' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.Android.Support.Animated.Vector.Drawable' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.AppCompat' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Maps' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.CardView' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android           
Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Gcm' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.RecyclerView' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.Android.Support.Design' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.MediaRouter' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.Animated.Vector.Drawable' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.  MyApp.Android           
Assembly 'Xamarin.Android.Support.Vector.Drawable' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.   MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Base' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android           
Assembly 'Xamarin.Android.Support.v7.MediaRouter' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author.    MyApp.Android           
Assembly 'Xamarin.GooglePlayServices.Basement' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]',which is no longer supported. Use a newer version of this NuGet package or notify the library author. MyApp.Android       

我尝试了什么?

1-我试图删除 bin obj 文件夹,以强制项目重建所有内容,但错误仍然出现

2-我试图降级到 16.4.4 ,并且错误消失了,但是我不想通过以下方式修复它之所以这样,是因为我想使用此new feature in 16.7.0

创建一个新的其他应用程序

因此,是否有办法在不降级到旧版本的情况下摆脱这些错误

注释:

Xamarin.Forms的版本为2.3

解决方法

Xamarin.Forms的版本为2.3

由于Visual Studio 2019不支持v2.3,因此您需要更新Xamarin.Forms的较新版本; Xamarin.Forms v2.3是released in 2016

我建议使用最新版本的Xamarin.Forms。

,

android版本10不支持Xamarin.Android.Support.v7 如果将目标框架版本更改为Android 9,则可以在设备中进行调试。

按照步骤

转到Android.project > properties > target framework

enter image description here

enter image description here

,

您能否尝试将android Target Framework(从项目属性或.csproj)升级到最新版本,如下所示:

enter image description here

在删除bin和obj文件夹后重建项目。应该可以。

来源:https://github.com/xamarin/AndroidX/issues/48