构建新的Xamarin.Forms项目失败

时间:2016-10-24 01:32:09

标签: c# android xamarin xamarin.forms

我正在尝试使用Xamarin Studio(6.1.1 build 15. macOS v10.12)创建一个新的Xamarin.Forms项目。 我得到了3个项目的解决方案。一个共享,一个用于iOS,一个用于Android。除了Android之外,一切都在构建。尝试编译资源时失败,特别是样式文件。

出现以下错误:

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'.
No resource found that matches the given name: attr 'colorPrimary'.
No resource found that matches the given name: attr 'colorPrimaryDark'.
No resource found that matches the given name: attr 'windowActionBar'.
No resource found that matches the given name: attr 'windowActionModeOverlay'.
No resource found that matches the given name: attr 'windowNoTitle'.
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'.

我尝试删除所有与Android支持相关的库和Xamarin.Forms本身,并使用NuGet再次添加它们。但这没有任何帮助。 我使用的Xamarin.Forms版本是2.3.2.127。

也许有人可以帮助我吗?

编辑: 这是发生错误的文件。我没有改变任何事情。这就是Xamarin产生的。

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="MyTheme" parent="MyTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MyTheme.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>

我还删除了所有包并重新添加了Xamarin.Forms。它会自动添加所需的支持包。但错误仍然存​​在。

1 个答案:

答案 0 :(得分:0)

我通过从https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/下载android_m2repository_r29.zip存储库并使用相同的指令解决了这个问题。