Why does material_dynamic_primary30 cause android.view.InflateException?

42 Views Asked by At
<Button
    android:id="@+id/buttonFoo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="@color/material_dynamic_primary30"
    android:padding="10dip"
    android:text="@string/foo" />

android:background="@color/material_dynamic_primary30 in the above code throws the following exception:

Stack trace: android.view.InflateException: Binary XML file line #252: Binary XML file line #252: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #252: Error inflating class Button
Caused by: android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f0602da
Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0602da
    at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:255)
    at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:785)
    at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:631)
    at android.content.res.Resources.loadDrawable(Resources.java:897)
    at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:955)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
    at android.view.View.<init>(View.java:5010)
    at android.widget.TextView.<init>(TextView.java:875)
    at android.widget.Button.<init>(Button.java:166)
    at android.widget.Button.<init>(Button.java:141)
    at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:81)
    at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:228)
    at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:224)
    at com.google.android.material.theme.MaterialComponentsViewInflater.createButton(MaterialComponentsViewInflater.java:43)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:156)
    at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1678)
    at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1729)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:775)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:197)
    at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
    at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)

Everything works flawlessly after android:background="@color/material_dynamic_primary30 is removed or replaced with android:background="@color/colorPrimaryDark". This button is in a large fragment.

Could anyone shed some light on this?

0

There are 0 best solutions below