[Snackbar] InflateException thrown on obfuscated builds
See original GitHub issueDescription: With ProGuard enabled (minifyEnabled and shrinkResources both true), the Snackbar component crashes with the following exception:
android.view.InflateException: Binary XML file line #1 in my.package.name:layout/mtrl_layout_snackbar_include: Binary XML file line #1 in my.package.name:layout/mtrl_layout_snackbar_include: Error inflating class x
Caused by: android.view.InflateException: Binary XML file line #1 in my.package.name:layout/mtrl_layout_snackbar_include: Error inflating class x
Caused by: java.lang.ClassNotFoundException: android.view.x
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at android.view.LayoutInflater.createView(LayoutInflater.java:815)
at android.view.LayoutInflater.createView(LayoutInflater.java:776)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:913)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:930)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:950)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
Expected behavior: Showing a Snackbar should not crash.
Source code:
Snackbar.make(view, "text", Snackbar.LENGTH_SHORT).show()
Android API version: 28, 29
Material Library version: The issue is present both in “1.3.0-alpha03” and “1.2.1”.
Device: Samsung Galaxy Note 10+, Google Pixel 3, OnePlus 5
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (2 by maintainers)
Top Results From Across the Web
Snackbar InflateException in Design Support Library 22.2.1
I'm trying to use the Snackbar from the Design Support Library 22.2.1 and I'm getting an InflateException . This is how I'm using...
Read more >Inflateexception When Trying To Use A Snackbar - ADocLib
InflateException: Binary XML file line #1 in [Snackbar] InflateException thrown on obfuscated builds #1814. Android design support library now includes ...
Read more >top5relatedtags - Stack Exchange Data Explorer
... 'project-management', 'build-automation', 'c++17', 'progressdialog', 'phalcon', 'soap-client', 'lucene.net', 'bytecode', 'android-wifi', ...
Read more >InflateException when trying to use a Snackbar - AndroidBugFix
Every time the Snackbar needs to be shown I get this exception: ... InflateException: Binary XML file line #41: Error inflating class ...
Read more >[FIXED] Why do I get the android.view.InflateException when using ...
1. First of all, create the perfect activity to load a fragment. MainActivity.class public class MainActivity extends AppCompatActivity { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding this to your
proguard-rules.pro
should fix the issue:-keep class com.google.android.material.snackbar.** { *; }
Maybe can be broken down to be more precise.
Tested with Gradle Plugin 7.0.0-alpha03
Seems this is an issue on the R8 side: https://issuetracker.google.com/issues/174167294