“找不到资源..."尝试编译空白的跨平台Xamarin应用程序 [英] "No resource found..." trying to compile a blank cross-platform Xamarin app

查看:74
本文介绍了“找不到资源..."尝试编译空白的跨平台Xamarin应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS Community 2015 Update3.我通过VS安装程序安装了Xamarin v4.2,然后通过Xamarin安装程序将其更新为4.2.1.60.

I'm using VS Community 2015, Update 3. I installed Xamarin v4.2 via the VS installer, then updated via a Xamarin installer to 4.2.1.60.

我创建了一个新的跨平台项目:Blank App (Xamarins.Forms Portable).我将Droid项目设置为Startup Project,然后右键单击BlankApp1.Droid尝试编译Android项目.

I created a new Cross-Platform project: Blank App (Xamarins.Forms Portable). I set the Droid project as Startup Project, and then right click on BlankApp1.Droid to try and compile the Android project.

我遇到以下编译错误:(错误在文件styles.xml中)

I am getting the following compile errors: (errors are in file styles.xml)

未找到与给定名称匹配的资源:attr'windowActionBar'.
找不到与给定名称匹配的资源:attr'windowNoTitle'.
找不到与给定名称匹配的资源:attr'colorPrimaryDark'.
找不到与给定名称匹配的资源:attr'colorPrimary'.
检索项目的父项时出错:找不到与以下项匹配的资源 命名为'Theme.AppCompat.Light.DarkActionBar'.
找不到与给定名称匹配的资源:attr'colorAccent'.
检索项目的父项时出错:找不到与以下项匹配的资源 命名为'Theme.AppCompat.Light.Dialog'.
找不到与给定名称匹配的资源:attr'colorAccent'.
找不到与给定名称匹配的资源:attr "windowActionModeOverlay".

No resource found that matches the given name: attr 'windowActionBar'.
No resource found that matches the given name: attr 'windowNoTitle'.
No resource found that matches the given name: attr 'colorPrimaryDark'.
No resource found that matches the given name: attr 'colorPrimary'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
No resource found that matches the given name: attr 'colorAccent'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
No resource found that matches the given name: attr 'colorAccent'.
No resource found that matches the given name: attr 'windowActionModeOverlay'.

Styles.xml:

Styles.xml:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>
    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>
</resources>

软件包配置:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Forms" version="2.3.2.127" targetFramework="monoandroid60" />
</packages>

该项目设置为使用最新的Android版本= 6.0进行编译.

The project is set to compile using the latest Android version = 6.0.

我还将Xamarin.Forms Nuget软件包从2.2.0.45更新到了2.3.2.127.我得到了相同的错误列表(尽管奇怪的是,错误的顺序是不同的...)

I also updated Xamarin.Forms Nuget Package from 2.2.0.45 to 2.3.2.127. I get the same list of errors (although, strangely the errors are in a different order...)

关于什么是问题以及如何解决的任何想法?

Any ideas of what the problem is and how to solve?

推荐答案

导航至:

C:\Users\username\AppData\Local\Xamarin\zips

找到此zip文件:

2A3A8A6D6826EF6CC653030E7D695C41.zip

现在删除此文件,然后返回Visual Studio,然后重新构建解决方案.根据您的连接速度,完全下载该文件需要花费一些时间,大约200 mb.

Now delete this file, then go back to Visual Studio and Rebuild Solution.. will take some time to fully download the file depending on your connection speed, it's around 200mb.

这篇关于“找不到资源..."尝试编译空白的跨平台Xamarin应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆