我遇到了一个我已经完成了Xamarin.Forms应用程序的问题。
目前,我正在尝试对Android服务进行单元测试。
所以目前这意味着我已经完成了以下任务:
在这之后,我创建了Xamarin UITest Android Project
现在,我添加了对Xamarin Forms.Droid项目的引用
每次启动必须在Android模拟器中运行的单元测试时,都无法找到主题。
位于PCL中的app.xml中
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<Color x:Key="BackgroundGlobal">#ff333333</Color>
<Color x:Key="MidGradient">#ff0d0d0d</Color>
<Color x:Key="BottomGradient">Black</Color>
<Color x:Key="MenuTextColor">Azure</Color>
<Style TargetType="ImageCell" x:Key="Clicky">
<Setter Property="TextColor" Value="{StaticResource MenuTextColor}"/>
<Setter Property="DetailColor" Value="Aqua"/>
</Style>
</ResourceDictionary>
</Application.Resources>
在Xamarin.Forms.Droid Resource \ Values \ strings.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">
<!--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>
我目前得到以下内容:
Severity Code Description Project File Line Suppression State Error
Error: No resource found that matches the given name (at 'theme' with value '@style/MainTheme'). Xamarin.Forms.Droid.Tests C:\dev\git\example\Xamarin.Forms.Droid.Tests\obj\Debug\android\manifest\AndroidManifest.xml 9