Search code examples
androidandroidxmigrateandroid-appbarlayout

AppBarLayout inflating error after migrating to 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

Solution

  • 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 is now com.google.android.material.appbar.AppBarLayout.

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

    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.