Error inflating class com.google.android.material.appbar.AppBarLayout

前端 未结 4 1958
时光说笑
时光说笑 2020-12-31 06:32

I have bellow xml:




        
相关标签:
4条回答
  • 2020-12-31 07:00

    You're using AndroidX tags-components which you already have AppCompat dependencies. This will cause other issues too. Go with the Refactor -> Migrate to AndoridX and add the mentioned dependency for the material components too.

    In your build.gradle dependencies:

    implementation 'com.google.android.material:material:1.0.0'
    

    It's coming from Material components -> com.google.android.material as you can see so, that's why you get the error.

    Remember to update the gradle in the other build.gradle too:

    classpath 'com.android.tools.build:gradle:3.2.0'
    
    0 讨论(0)
  • 2020-12-31 07:06

    Don't forget to use Theme.MaterialComponents.Light.NoActionBar (or any Theme.MaterialComponents.*.NoActionBar really) as your parent AppTheme in style.xml (source).

    0 讨论(0)
  • 2020-12-31 07:06

    Check your /res/values/styles.xml and set your theme to

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />
    

    or similar

    0 讨论(0)
  • 2020-12-31 07:13
    implementation 'com.google.android.material:material:1.0.0'
    classpath 'com.android.tools.build:gradle:3.2.0'
    

    If you have added the above two conditions and it's still showing the error you can try a "LinearLayout" instead.

    0 讨论(0)
提交回复
热议问题