mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

Update from 8.4.5 to 9.0.0-a3, BezelImageView crashes #2759

Closed onlymash closed 2 years ago

onlymash commented 2 years ago
java.lang.RuntimeException: Unable to start activity ComponentInfo{MainActivity}: android.view.InflateException: Binary XML file line #26 in layout/material_drawer_header: Binary XML file line #26 in layout/material_drawer_header: Error inflating class com.mikepenz.materialdrawer.view.BezelImageView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3639)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3796)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2214)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
     Caused by: android.view.InflateException: Binary XML file line #26 in layout/material_drawer_header: Binary XML file line #26 in layout/material_drawer_header: Error inflating class com.mikepenz.materialdrawer.view.BezelImageView
     Caused by: android.view.InflateException: Binary XML file line #26 in layout/material_drawer_header: Error inflating class com.mikepenz.materialdrawer.view.BezelImageView
     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:858)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:660)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
        at com.mikepenz.materialdrawer.widget.AccountHeaderView.<init>(AccountHeaderView.kt:412)
        at com.mikepenz.materialdrawer.widget.AccountHeaderView.<init>(AccountHeaderView.kt:35)
        at MainActivity.setupDrawer(MainActivity.kt:259)
        at MainActivity.onCreate(MainActivity.kt:197)
        at android.app.Activity.performCreate(Activity.java:8051)
        at android.app.Activity.performCreate(Activity.java:8031)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3612)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3796)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2214)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
2021-11-24 19:55:01.103 6670-6670/ E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 2: TypedValue{t=0x2/d=0x7f040109 a=8}
        at android.content.res.TypedArray.getColor(TypedArray.java:529)
        at com.mikepenz.materialdrawer.view.BezelImageView.<init>(BezelImageView.kt:82)
        at com.mikepenz.materialdrawer.view.BezelImageView.<init>(BezelImageView.kt:43)
        at com.mikepenz.materialdrawer.view.BezelImageView.<init>(Unknown Source:11)
mikepenz commented 2 years ago

@onlymash what's your activities theme?

onlymash commented 2 years ago

@mikepenz

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
        <!-- MaterialDrawer specific values -->
        <item name="materialDrawerStyle">@style/MaterialDrawerStyle</item>
        <item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>
    </style>
<style name="MaterialDrawerStyle" parent="Widget.MaterialDrawerStyle">
        <item name="materialDrawerBackground">?android:colorBackground</item>
        <item name="materialDrawerDividerColor">@color/colorDividerItem</item>
    </style>
onlymash commented 2 years ago

It seems that I need to change the theme to material3, I'm sorry it was my mistake

carlos-mg89 commented 2 years ago

@onlymash could you please tell me where exactly did you change the theme? The same error appears in the error log with the final 9.0.0 release in my app.

My app theme is this one:

<style name="App.DayNight" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
</style>

And in the build.gradle there's this dependency, which is the latest version (there are newer versions, but in beta or alpha):

implementation "com.google.android.material:material:1.5.0"

Hope you don't mind me asking.

carlos-mg89 commented 2 years ago

Alright, I just checked the release notes of 9.0.0, and found the reference about the Material3, and then investigated a bit about it.

To use Material3 requires a change in the base style theme. So I changed the above:

Theme.MaterialComponents.Light.NoActionBar.Bridge

with this:

Theme.Material3.Light.NoActionBar

And now the app runs without crashing.