question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Snackbar] InflateException thrown on obfuscated builds

See original GitHub issue

Description: 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:closed
  • Created 3 years ago
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
giacomoferretticommented, Dec 20, 2020

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

1reaction
xizzhucommented, Feb 19, 2021

Seems this is an issue on the R8 side: https://issuetracker.google.com/issues/174167294

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found