Error : IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents
Solution 1:
There is some issue with material:1.1.0-alpha01
A simple solution is to change the parent theme
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Solution 2:
Extend your base app Theme from Material Components Bridge theme. It extends AppCompat theme, but adds all necessary stuff.
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.Bridge">
<!-- ... -->
</style>
Both
Theme.MaterialComponents
andTheme.MaterialComponents.Light
have.Bridge
themes:
Theme.MaterialComponents.Bridge
Theme.MaterialComponents.Light.Bridge
Theme.MaterialComponents.NoActionBar.Bridge
Theme.MaterialComponents.Light.NoActionBar.Bridge
Theme.MaterialComponents.Light.DarkActionBar.Bridge
It allows you to keep using latest version of the library, but avoid a lot of UI issues, caused by migration to pure Material Component theme
https://material.io/develop/android/docs/getting-started/#bridge-themes
Solution 3:
Adding theme directly to widget works too. E.g.:
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggle_button_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/Theme.MaterialComponents.Light"> <======== THIS
Checked with min. SDK ver. 21.
Solution 4:
None of these worked for me. Must do these two things.
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme -->
</style>
and
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
app:theme="@style/Theme.MaterialComponents"