14

Sometimes, on different mobiles (Android 7) there is this crash:

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in com.google.firebase.iid.zzae@3c68978
       at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1178)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6321)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnected()' on a null object reference
       at com.google.firebase.iid.zzad.zzchr(Unknown Source)
       at com.google.firebase.iid.zzae.onReceive(Unknown Source)
       at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1163)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6321)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Have you seen this error before? I don't know how to correct this bug...

Thank you very much guys!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
anthony
  • 7,653
  • 8
  • 49
  • 101
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Ratilal Chopda Dec 05 '17 at 09:22
  • 4
    What?? Did you read correctly my post?? – anthony Dec 05 '17 at 09:24
  • 1
    please share your code – Kanaiya Katarmal Dec 05 '17 at 09:26
  • I have no code linked directly with this crash. That's why it's really difficult! – anthony Dec 05 '17 at 09:31
  • 1
    You have to share the code first. See this error occurred where you're checking for a working internet connection. – Lalit Fauzdar Dec 05 '17 at 09:35
  • Did you see the stack traces? There is no link directly with my App. I can't post my entire App source code! – anthony Dec 05 '17 at 09:39
  • I do not think there is any issue with the code, the "Error receiving broadcast..." happens for an unhandled exception, which in this case is which in this case is Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnected()' on a null object reference. Since, there is already a null check present for network info in the code. There can be two possibilities. You are using an old compilation of the SDK or your IDE is behaving strangely. – Puneet Kala Dec 05 '17 at 10:08
  • Are you calling this in inside your MainActivity or a background service?. Please post the code of that class – lakshman.pasala Dec 05 '17 at 16:52
  • 4
    We are seeing the same issue. Most likely this is a bug with their SDK. Firebase team keeps screwing up royally... – inteist Dec 07 '17 at 21:13
  • 1
    I experience the exact same crash. And I use their latest release 11.6.2 The stack trace is pointing to FirebaseInstanceIdReceiver – Gal Rom Dec 10 '17 at 08:51
  • 2
    Opened an issue on Tracker: https://issuetracker.google.com/issues/70451836 – Gal Rom Dec 10 '17 at 09:27
  • may help https://stackoverflow.com/questions/44692869/internet-connectivity-causes-null-pointer-exception-in-android-application – amorenew Dec 18 '17 at 06:36

2 Answers2

1

The issue has been fixed in 11.8.0 . Please update your Firebase SDK version. Refer https://firebase.google.com/support/release-notes/android#20171218

Harshit Jain
  • 142
  • 1
  • 4
0
final boolean zzchr() {
    ConnectivityManager var1;
    return (var1 = (ConnectivityManager)this.getContext().getSystemService("connectivity")) != null && var1.getActiveNetworkInfo() != null && var1.getActiveNetworkInfo().isConnected();
}

This is the code for zzchr. There is already a null check added for getActiveNetworkInfo but you are still getting NPE.

You can check on other possibilities of NPE here. Hope it helps.

Puneet Kala
  • 150
  • 2
  • 11