有时,在不同的手机(Android 7)上会出现这种崩溃:
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)
你以前见过这个错误吗?我不知道如何纠正这个错误...
非常感谢你们!
答案 0 :(得分:1)
该问题已在11.8.0中修复。请更新您的Firebase SDK版本。 请参阅https://firebase.google.com/support/release-notes/android#20171218
答案 1 :(得分:0)
final boolean zzchr() {
ConnectivityManager var1;
return (var1 = (ConnectivityManager)this.getContext().getSystemService("connectivity")) != null && var1.getActiveNetworkInfo() != null && var1.getActiveNetworkInfo().isConnected();
}
这是zzchr的代码。已经为getActiveNetworkInfo添加了空检查,但您仍然在获得NPE。
您可以查看NPE here的其他可能性。希望它有所帮助。