Android Snackbar crashes(android.view.InflateException) with enabled Proguard


In the Firebase, I start receiving these stack traces:

Fatal Exception: android.view.InflateException
Binary XML file line #1 in {my_project_package_name}:layout/mtrl_layout_snackbar_include: Binary XML file line #1 in {my_project_package_name}:layout/mtrl_layout_snackbar_include: Error inflating class x

The application sometimes also crashes with enabled Proguard when Snackbar is shown.


I checked the source code of the mtrl_layout_snackbar_include.xml file and found that it depends on the custom google material component:


Since we have a Proguard, this class name will be changed in the compile time.

I fixed this issue by adding these rules to the Proguard to exclude this class name.

# Snackbar
-keep class** { *; }
-keep interface** { *; }
-keep public class$* { *; }

Answered By – Veniamin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published