Android多模块应用由于材料成分而导致UI测试失败

问题描述 投票:0回答:1

我有一个小型的多模块应用程序,我在其中使用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导入模块appfeature_module中,但还是没有运气。

非常感谢!

android android-espresso material-components-android
1个回答
0
投票

Theme.MaterialComponents.DayNight.NoActionBarTheme.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"

© www.soinside.com 2019 - 2024. All rights reserved.