Skip to content

[MaterialCheckBox] Crash with .Bridge theme and checkBoxStyle #765

@pawelkw

Description

@pawelkw

Description: App crashes when these 3 conditions are met:

  • layout features a MaterialCheckBox
  • .Bridge theme is used
  • checkBoxStyle is set and inherits from Widget.MaterialComponents.CompoundButton.CheckBox

Expected behavior: App doesn't crash

Android API version: 29

Material Library version: 1.1.0-beta01

Device: Emulator x86

Stack trace:

2019-11-15 16:29:12.941 18783-18783/com.test.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.test.app, PID: 18783
    android.view.InflateException: Binary XML file line #51 in com.test.app:layout/registration_page_1: Binary XML file line #51 in com.test.app:layout/registration_page_1: Error inflating class com.google.android.material.checkbox.MaterialCheckBox
    Caused by: android.view.InflateException: Binary XML file line #51 in com.test.app:layout/registration_page_1: Error inflating class com.google.android.material.checkbox.MaterialCheckBox
    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 androidx.fragment.app.Fragment.onCreateView(Fragment.java:1737)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2695)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:286)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1232)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1398)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1476)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:442)
        at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2333)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2120)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2075)
        at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1946)
        at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:297)
        at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341)
        at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276)
        at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67)
        at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7547)
        at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:860)
        at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8592)
        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8550)
        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8538)
        at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1641)
        at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
        at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4132)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3849)
        at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4402)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:514)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1656)
        at android.view.View.layout(View.java:21912)
2019-11-15 16:29:12.943 18783-18783/com.test.app E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1656)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1231)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
        at android.view.Choreographer.doCallbacks(Choreographer.java:790)
        at android.view.Choreographer.doFrame(Choreographer.java:725)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 36: TypedValue{t=0x2/d=0x7f030263 a=6}
        at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:781)
        at android.view.View.<init>(View.java:5519)
        at android.widget.TextView.<init>(TextView.java:974)
        at android.widget.Button.<init>(Button.java:166)
        at android.widget.CompoundButton.<init>(CompoundButton.java:100)
2019-11-15 16:29:12.943 18783-18783/com.test.app E/AndroidRuntime:     at android.widget.CheckBox.<init>(CheckBox.java:69)
        at android.widget.CheckBox.<init>(CheckBox.java:65)
        at androidx.appcompat.widget.AppCompatCheckBox.<init>(AppCompatCheckBox.java:69)
        at com.google.android.material.checkbox.MaterialCheckBox.<init>(MaterialCheckBox.java:65)
        at com.google.android.material.checkbox.MaterialCheckBox.<init>(MaterialCheckBox.java:61)
        	... 101 more

Same happens when I use CheckBox directly instead of com.google.android.material.checkbox.MaterialCheckBox

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions