【问题标题】:Compile errors when creating a basic Xamarin.Android project创建基本 Xamarin.Android 项目时出现编译错误
【发布时间】:2017-12-25 20:09:53
【问题描述】:

我正在尝试开始使用 Xamarin 进行开发。我正在使用以下 Visual Studio 版本:

Microsoft Visual Studio Enterprise 2017 版本 15.5.2 (VisualStudio.15.Release/15.5.2+27130.2010) Microsoft .NET 框架版本 4.7.02556

我创建了一个新的 Xamarin 项目并收到以下错误(未添加任何代码)。我尝试重新安装 Xamarin,但没有成功。有关如何解决此问题的任何想法?

Severity    Code    Description Project File    Line    Suppression State
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  12  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  12  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  12  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  13  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  15  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  17  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  18  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  20  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  22  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  23  Active
Error   CS0012  The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  23  Active
Error   NU1202  Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)             
Error   NU1202  Package Xamarin.Android.Support.v7.CardView 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.CardView 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)               
Error   NU1202  Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)             
Error   NU1202  Package Xamarin.Android.Support.v4 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v4 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)             
Error   NU1202  Package Xamarin.Android.Support.Design 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.Design 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)             
Error   CS1503  Argument 1: cannot convert from 'App4.Droid.MainActivity' to 'Android.Content.Context'  App4.Android    C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs  22  Active

【问题讨论】:

  • 您是否尝试为您的项目恢复 nuget 包?您正在创建什么样的 Xamarin 项目?
  • 你看过at this question吗?

标签: xamarin xamarin.android


【解决方案1】:

您是否更新了所有软件包?不久前我收到此错误并更新它们为我修复了它(工具 -> NuGet 包管理器 -> 管理解决方案的 NuGet 包 -> 更新,然后全部更新)

【讨论】:

    猜你喜欢
    • 2018-07-10
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-04
    • 2021-04-28
    • 2020-08-12
    相关资源
    最近更新 更多