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

前端 未结 7 989
悲哀的现实
悲哀的现实 2020-12-19 06:11

After I updated my project to AndroidX with targetSdkVersion set to 28, my project crashes on installing it from the store for beta testing.

<
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 06:43

    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.

提交回复
热议问题