Reputation: 1800
Two days i was stuck with IllegalArgument Exception(given the crash log below) while clicking on the custom AppCompatSpinner. This issue is not happening in all devices, only few devices(Samsung, Oneplus) affected. App themes are listed below for all the api version
parent="Theme.AppCompat.NoActionBar"
v23 theme:
parent="Theme.AppCompat.Light.NoActionBar"
v21 theme :
parent="Theme.MaterialComponents.DayNight.NoActionBar"
My crash log:
E/AndroidRuntime: FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #95: Binary XML file line #37: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class Button
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
Please give some insights to fix this issue. Found some solutions in stackoverflow & other sites but nothing helped me to fix the issue
Upvotes: 0
Views: 67
Reputation: 2056
If you want to use Material UI elements, then
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
should be changed to <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
.
As the error itself is saying, your app theme must be a child of MaterialTheme
or any child of the same.
Upvotes: 0