我有一个小型的多模块应用程序,我在其中使用Google的Material Components。该应用程序可以完美运行,但是当我运行Espresso测试时,如果失败,则:
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
当前,我的应用程序中唯一引用MaterialComponents的位置是在app
中的values/styles.xml
模块中,并带有
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
我是否需要在功能模块中添加其他功能,这就是我要测试的功能?我目前在我的gradle文件implementation(SupportLibs.MATERIAL)
中将Google Material Component导入模块app
和feature_module
中,但还是没有运气。
非常感谢!
Theme.MaterialComponents.DayNight.NoActionBar
或Theme.MaterialComponents.DayNight.NoActionBar.DarkActionBar
中没有[C0
同样,如果您还没有这样做,则需要将其添加到gradle文件中:
Theme.MaterialComponents.DayNight.NoActionBar.DarkActionBar.Bridge
//Material
implementation "com.google.android.material:material:1.0.0"
// or "1.2.0-alpha06"