更新 Nuget 包后无法构建 Xamarin Android 应用程序

Unable to build Xamarin Android App after updating Nuget Package

我更新了我的应用程序以引用兼容性库的 v23 (Xamarin.Android.Support.v7.AppCompat version="23.3.0") 并且无法再构建该应用程序。我收到以下错误:

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.

No resource found that matches the given name: attr 'windowActionBar'.

No resource found that matches the given name: attr 'windowActionModeOverlay'.

重现步骤:

  1. 在 Visual Studio 中创建一个新的 Android 项目(空白项目)
  2. 安装包Xamarin.Android.Support.v7.AppCompat(通过 nuget)
  3. 使用以下文本在值文件夹中创建名为 styles.xml 的文件

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:colorPrimary">@color/PrimaryColor</item>
    <item name="android:colorPrimaryDark">@color/PrimaryDarkColor</item>
    <item name="windowActionBar">false</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
  </style>
  
</resources>

必须卸载 nuget 包然后删除 zip 文件和支持目录:

C:\Users[用户]\AppData\Local\Xamarin

我遇到了同样的问题,但这是安装最新的 android sdk(Android 7 Nouget 和 img)的解决方案,重新启动您的 visual studio 或 ide,然后尝试安装 nuget 包。