迁移到AndroidX后,AppBarLayout膨胀错误 [英] AppBarLayout inflating error after migrating to AndroidX

查看:139
本文介绍了迁移到AndroidX后,AppBarLayout膨胀错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

迁移到AndroidX时,我遇到了这个问题:

When migrating to AndroidX I faced this problem:

Java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.mandarine.android/com.mandarine.android.features.root.RootActivity}:
android.view.InflateException: Binary XML file line #18: Binary XML file line #18:
Error inflating class android.support.design.widget.AppBarLayout

推荐答案

除非实现旧的支持库并启用Jetifier,否则必须重命名XML中的所有支持类.

Unless you implement the old support libraries and enable Jetifier, you have to rename all your support classes in XML.

android.support.design.widget.AppBarLayout现在是com.google.android.material.appbar.AppBarLayout.

为此,您可能需要在build.gradle中使用implementation 'com.google.android.material:material:1.0.0-beta01'.

You may need to use implementation 'com.google.android.material:material:1.0.0-beta01' in your build.gradle for this.

使用支持库查找XML中的任何其他视图,然后重命名标签以匹配其AndroidX版本.您只需在Google中搜索"ClassName AndroidX",即可找到该类的文档.

Look for any other Views in XML using the support library and rename the tags to match their AndroidX versions. You can simply search "ClassName AndroidX" in Google and you'll find the documentation for that class.

这篇关于迁移到AndroidX后,AppBarLayout膨胀错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆