Material-components-android: MaterialTimePicker crashed when exporting with shrinkResources = true.

Created on 24 Jul 2020  路  2Comments  路  Source: material-components/material-components-android

Android Studio and gradle 4.1.0-beta05
Material design 1.3.0-alpha02
Device test: Xiaomi Redmi Note 4 Android 7.0, S10+ Android 10

 release {
     minifyEnabled true
     shrinkResources true // need to turn off to fix this bug
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Process: com.myapp, PID: 15960
    android.view.InflateException: Binary XML file line #45 in com.myapp:layout/material_timepicker_dialog: Binary XML file line #45 in com.myapp:layout/material_timepicker_dialog: Error inflating class com.google.android.material.timepicker.TimePickerView
    android.view.InflateException: Binary XML file line #45 in com.myapp:layout/material_timepicker_dialog: Binary XML file line #45 in com.myapp:layout/material_timepicker_dialog: Error inflating class com.google.android.material.timepicker.TimePickerView
    Caused by: android.view.InflateException: Binary XML file line #45 in com.myapp:layout/material_timepicker_dialog: Error inflating class com.google.android.material.timepicker.TimePickerView
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at com.google.android.material.timepicker.b.v0(MaterialTimePicker.java:2)
        at androidx.fragment.app.Fragment.Y0(Fragment.java:4)
        at androidx.fragment.app.d.Y0(DialogFragment.java:1)
        at androidx.fragment.app.v.e(FragmentStateManager.java:15)
        at androidx.fragment.app.n.O0(FragmentManager.java:14)
        at androidx.fragment.app.n.N0(FragmentManager.java:1)
        at androidx.fragment.app.n.L0(FragmentManager.java:4)
        at androidx.fragment.app.n.M0(FragmentManager.java:8)
        at androidx.fragment.app.a.w(BackStackRecord.java:31)
        at androidx.fragment.app.n.c0(FragmentManager.java:6)
        at androidx.fragment.app.n.d0(FragmentManager.java:21)
        at androidx.fragment.app.n.Y0(FragmentManager.java:10)
        at androidx.fragment.app.n.a0(FragmentManager.java:4)
        at androidx.fragment.app.n$g.run(FragmentManager.java:1)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
     Caused by: android.view.InflateException: Binary XML file line #23 in com.myapp:layout/material_timepicker: Binary XML file line #32 in com.myapp:layout/material_clock_display: Error inflating class com.google.android.material.chip.Chip
     Caused by: android.view.InflateException: Binary XML file line #32 in com.myapp:layout/material_clock_display: Error inflating class com.google.android.material.chip.Chip
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1263)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1119)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:656)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at com.google.android.material.timepicker.TimePickerView.<init>(TimePickerView.java:4)
2020-07-24 09:22:44.273 15960-15960/? E/AndroidRuntime:     at com.google.android.material.timepicker.TimePickerView.<init>(TimePickerView.java:1)
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at com.google.android.material.timepicker.b.v0(MaterialTimePicker.java:2)
        at androidx.fragment.app.Fragment.Y0(Fragment.java:4)
        at androidx.fragment.app.d.Y0(DialogFragment.java:1)
        at androidx.fragment.app.v.e(FragmentStateManager.java:15)
        at androidx.fragment.app.n.O0(FragmentManager.java:14)
        at androidx.fragment.app.n.N0(FragmentManager.java:1)
        at androidx.fragment.app.n.L0(FragmentManager.java:4)
        at androidx.fragment.app.n.M0(FragmentManager.java:8)
        at androidx.fragment.app.a.w(BackStackRecord.java:31)
        at androidx.fragment.app.n.c0(FragmentManager.java:6)
        at androidx.fragment.app.n.d0(FragmentManager.java:21)
        at androidx.fragment.app.n.Y0(FragmentManager.java:10)
        at androidx.fragment.app.n.a0(FragmentManager.java:4)
        at androidx.fragment.app.n$g.run(FragmentManager.java:1)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
     Caused by: android.content.res.Resources$NotFoundException: Can't find ColorStateList from drawable resource ID #0x7f0600bb
        at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:1222)
        at android.content.res.Resources.loadColorStateList(Resources.java:1163)
        at android.content.res.TypedArray.getColorStateList(TypedArray.java:599)
        at android.widget.TextView.readTextAppearance(TextView.java:4270)
        at android.widget.TextView.<init>(TextView.java:1325)
        at android.widget.Button.<init>(Button.java:181)
        at android.widget.CompoundButton.<init>(CompoundButton.java:110)
        at android.widget.CheckBox.<init>(CheckBox.java:69)
        at android.widget.CheckBox.<init>(CheckBox.java:65)
        at androidx.appcompat.widget.g.<init>(AppCompatCheckBox.java:2)
        at com.google.android.material.chip.Chip.<init>(Chip.java:2)
        at com.google.android.material.chip.Chip.<init>(Chip.java:1)
bug

Most helpful comment

Thanks @kimcy929 seems to be a typo on my side.

As a workaround you can add this to your styles while we fix it

    <style name="Widget.MaterialComponents.TimePicker.Display" parent="Widget.MaterialComponents.Chip.Choice">
        <item name="android:layout_width">96dp</item>
        <item name="android:layout_height">80dp</item>
        <item name="ensureMinTouchTargetSize">false</item>
        <item name="android:textAlignment">center</item>
        <item name="android:textAppearance">?attr/textAppearanceHeadline3</item>
        <!-- No need to scale here since the text is already readable -->
        <item name="android:textSize" tools:ignore="SpUsage">56dp</item>
        <item name="shapeAppearanceOverlay">?shapeAppearanceMediumComponent</item>
    </style>

All 2 comments

Thanks @kimcy929 seems to be a typo on my side.

As a workaround you can add this to your styles while we fix it

    <style name="Widget.MaterialComponents.TimePicker.Display" parent="Widget.MaterialComponents.Chip.Choice">
        <item name="android:layout_width">96dp</item>
        <item name="android:layout_height">80dp</item>
        <item name="ensureMinTouchTargetSize">false</item>
        <item name="android:textAlignment">center</item>
        <item name="android:textAppearance">?attr/textAppearanceHeadline3</item>
        <!-- No need to scale here since the text is already readable -->
        <item name="android:textSize" tools:ignore="SpUsage">56dp</item>
        <item name="shapeAppearanceOverlay">?shapeAppearanceMediumComponent</item>
    </style>

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magnusfernandes picture magnusfernandes  路  3Comments

jaychang0917 picture jaychang0917  路  3Comments

Mirmuhsin picture Mirmuhsin  路  3Comments

TdevM picture TdevM  路  3Comments

gabrielemariotti picture gabrielemariotti  路  3Comments