Error inflating class com.google.android.material.navigation.NavigationView after migration to AndroidX

There are multiple reasons why this error can occur. Check the following and make sure they are proper:

  • Check your code for drawable and color resources used inside the com.google.android.material.navigation.NavigationView you've used, probably in activity_main.xml, if you're using the default Navigation Drawer template code from Android Studio.
  • Check that the drawable files are in res/drawable folder, not in res/drawable-v21.
  • Check if you've used android:backgroundTint() or android:src or similar inside your NavigationView. Since they don't work below android API Level 21, use app:backgroundTint or app:srcCompat instead.

In my case the problem was the theme value in the Manifest file

<activity
        android:name=".ui.BarcodeReaderDrawerActivity"
        android:label="@string/title_activity_barcode_reader_drawer">
        android:theme="@style/AppBaseTheme.NoActionBar"
    </activity>

Changed in

<activity
        android:name=".ui.BarcodeReaderDrawerActivity"
        android:label="@string/title_activity_barcode_reader_drawer"
        android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
    </activity>