Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 701
Morozov Avatar asked Nov 06 '18 13:11

Morozov


2 Answers

I used AS 3.2 Migrate to AndroidX wizard. But it failed to migrate some classes. Below are some I have encountered on my project. The second entry is the correct one

android.support.design.widget.BottomSheetDialog
com.google.android.material.bottomsheet.BottomSheetDialog 

android.support.design.widget.TextInputLayout
com.google.android.material.textfield.TextInputLayout 

android.support.design.widget.CoordinatorLayout
androidx.coordinatorlayout.widget.CoordinatorLayout

android.support.design.widget.NavigationView
com.google.android.material.navigation.NavigationView

androidx.core.view.ViewPager
androidx.viewpager.widget.ViewPager

android.support.design.widget.BottomSheetBehavior
com.google.android.material.bottomsheet.BottomSheetBehavior 

android.support.v7.widget.Toolbar
androidx.appcompat.widget.Toolbar 

android.support.design.internal.BottomNavigationItemView
com.google.android.material.bottomnavigation.BottomNavigationItemView

android.support.design.internal.BottomNavigationMenuView
com.google.android.material.bottomnavigation.BottomNavigationMenuView 

androidx.appcompat.widget.CardView
androidx.cardview.widget.CardView 

android.support.design.widget.BottomNavigationView
com.google.android.material.bottomnavigation.BottomNavigationView

androidx.core.view.ViewPager
androidx.viewpager.widget.ViewPager

importandroidx.core.widget.DrawerLayout
androidx.drawerlayout.widget.DrawerLayout 

androidx.appcompat.widget.RecyclerView
androidx.recyclerview.widget.RecyclerView 

androidx.core.view.PagerAdapter
androidx.viewpager.widget.PagerAdapter

importandroidx.core.app.FragmentManager
importandroidx.fragment.app.FragmentManager
like image 75
makata Avatar answered Oct 16 '22 12:10

makata


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.

like image 13
TheWanderer Avatar answered Oct 16 '22 11:10

TheWanderer