Error : IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents
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>
The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant)
found the solution ,get your inflator from activity not application just modify your initLayout()
like this
// here is the fix
val inflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
TextInputLayout Material Component Issue : The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant)
I just notice that it is possible just put the Material Components theme in the root view of a XML layout then you can now apply the style without any error.
In the parent/root view add this
android:theme="@style/Theme.MaterialComponents.Bridge"
Then apply the style to child view TextInputLayout
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/firstName"
style="@style/CustomInputStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/first_name"
android:inputType="text|textCapWords"
android:nextFocusDown="@id/lname"
style="@style/CustomEditText"
android:textSize="12sp" />
</com.google.android.material.textfield.TextInputLayout>
java.lang.IllegalArgumentException: This component requires that you specify a valid android:textAppearance attribute
Does your theme extend from Theme.MaterialComponents
? More info about how to ensure all the components will work correctly can be found at https://material.io/develop/android/docs/getting-started/
Material Alert Dialog, The style on this component requires your app theme to be Theme.AppCompat
You're passing in getApplicationContext()
and the application context doesn't have your theme. Pass in your activity as the context:
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(MainActivity.this)
.setTitle("Title")
.setMessage("Message")
builder.show();
IllegalArgumentException When trying to use @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox
As reported in the error:
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant)
You have to change the app theme to a Material Components Theme like:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- ... -->
</style>
CreateFromRessource ChipDrawable : The style on this component requires your app theme to be Theme.MaterialComponents
The issue is here:
ChipDrawable chip = ChipDrawable.createFromResource(getApplicationContext(),
The ApplicationContext
doesn't have your app theme.
You need to pass the Activity
, not an Application Context.
Related Topics
How to Create a Multilingual Android Application
How to Add Action Bar Options Menu in Android Fragments
Make a Hyperlink Textview in Android
Offline Mode for Android App Using the Google Maps API
Android Seekbar with Two Thumbs
Android Taking Screenshot of Offscreen Page
Play Rtsp Streaming in an Android Application
Glide-4.0.0 Missing Placeholder, Error, Glideapp and Does Not Resolve Its Method Placeholder,Error
Sending a File Using Bluetooth Obex Object Push Profile (Opp)
Android - Hide All Shown Toast Messages
Fast Ways to Import Drawables in Android Studio
How to Create Expandable Listview in Flutter
Don't Keep Activities - What Is It For
Send a Notification When the App Is Closed