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.

[BaseTransientBottomBar] 1.1.0-rc01 causes View.invalidate(boolean) NullPointerException

See original GitHub issue

Description: After updating from Material 1.0.0 to 1.1.0-rc01 I saw multiple reports of crashes with BaseTransientBottomBar (and no app specific code in stacktrace). Stacktraces look like: Huawei Android 7

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
       at android.view.View.setFlags + 11550(View.java:11550)
       at android.view.View.setVisibility + 8046(View.java:8046)
       at com.google.android.material.snackbar.BaseTransientBottomBar$9.run + 849(BaseTransientBottomBar.java:849)
       at android.os.Handler.handleCallback + 761(Handler.java:761)
       at android.os.Handler.dispatchMessage + 98(Handler.java:98)
       at android.os.Looper.loop + 156(Looper.java:156)
       at android.app.ActivityThread.main + 6617(ActivityThread.java:6617)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 942(ZygoteInit.java:942)
       at com.android.internal.os.ZygoteInit.main + 832(ZygoteInit.java:832)

Samsung Android 9

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
       at android.view.View.setFlags + 15721(View.java:15721)
       at android.view.View.setVisibility + 10789(View.java:10789)
       at com.google.android.material.snackbar.BaseTransientBottomBar$9.run + 849(BaseTransientBottomBar.java:849)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 214(Looper.java:214)
       at android.app.ActivityThread.main + 7094(ActivityThread.java:7094)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main + 975(ZygoteInit.java:975)

Xiaomi Android 9

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
       at android.view.View.setFlags + 14186(View.java:14186)
       at android.view.View.setVisibility + 10007(View.java:10007)
       at com.google.android.material.snackbar.BaseTransientBottomBar$9.run + 849(BaseTransientBottomBar.java:849)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 201(Looper.java:201)
       at android.app.ActivityThread.main + 6823(ActivityThread.java:6823)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 547(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main + 873(ZygoteInit.java:873)

LGE Android 9

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
       at android.view.View.setFlags + 14222(View.java:14222)
       at android.view.View.setVisibility + 10027(View.java:10027)
       at com.google.android.material.snackbar.BaseTransientBottomBar$9.run + 849(BaseTransientBottomBar.java:849)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 193(Looper.java:193)
       at android.app.ActivityThread.main + 6854(ActivityThread.java:6854)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 493(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main + 860(ZygoteInit.java:860)

(if needed I can find few more stacktrace, but they seem to differ just by line numbers)

Expected behavior: BaseTransientBottomBar should not cause crashes/NPE

Steps to reproduce are unfortunately unknown, it seems to be relatively rare. The issue did not happen in 1.0.0

Material Library version: 1.1.0-rc01

Device: Multiple Devices/Android OS versions affected.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
BYogatamacommented, Sep 15, 2021

Having same issue on Android 5, with com.google.android.material:material:1.4.0

 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
        at android.view.View.setFlags(View.java:9682)
        at android.view.View.setVisibility(View.java:6663)
        at android.widget.FrameLayout.setVisibility(FrameLayout.java:208)
        at com.google.android.material.snackbar.BaseTransientBottomBar$10.run(BaseTransientBottomBar.java:896)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
2reactions
vonox7commented, Jan 21, 2021

Fyi: Some issues are still present, see https://github.com/material-components/material-components-android/pull/1938. E.g.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.invalidate(boolean)' on a null object reference
       at android.view.View.setFlags(View.java:15710)
       at android.view.View.setVisibility(View.java:10777)
       at com.google.android.material.snackbar.BaseTransientBottomBar$10.run(BaseTransientBottomBar.java:896)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:6981)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

As a possible workaround you might use implementation 'com.github.material-components:material-components-android:d9fa78f176' as jitpack-dependency, in that version the NPEs are resolved.

@wcshi since the issue is only partially resolved, you might open this issue again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NullPointerException with boolean - Stack Overflow
Boolean instance with a primitive boolean , which means unboxing the java.lang.Boolean . Since null can't be unboxed, a NullPointerException is thrown.
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
NullPointerException at androidx.compose.ui.platform ...
Hello, noticed a NPE crash in compose ui after updating from 1.1.0-alpha05 to 1.1.0-beta01. Crash happening in RenderNodeLayer.
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
Some of the common reasons for NullPointerException in java programs are: Invoking a method on an object instance but at runtime the object...
Read more >
Fix "java.lang.NullPointerException" in Android Studio
Hey Geeks, today we will see what NullPointerException means and how we ... a default value set to it(Ex: True and False value...
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