java.lang.NullPointerException: Attempt to read from field 'int com.android.okio.Segment.limit' on a null object reference
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int com.android.okio.Segment.limit' on a null object reference at com.android.okio.OkBuffer.write + 574(OkBuffer.java:574) at com.android.okio.OkBuffer.read + 610(OkBuffer.java:610) at com.android.okio.RealBufferedSource.read + 56(RealBufferedSource.java:56) at com.android.okhttp.internal.http.HttpConnection$FixedLengthSource.read + 469(HttpConnection.java:469) at com.android.okhttp.internal.Util.skipAll + 227(Util.java:227) at com.android.okhttp.internal.http.HttpConnection.discard + 239(HttpConnection.java:239) at com.android.okhttp.internal.http.HttpConnection$FixedLengthSource.close + 491(HttpConnection.java:491) at com.android.okio.RealBufferedSource.close + 204(RealBufferedSource.java:204) at com.android.okio.RealBufferedSource$1.close + 187(RealBufferedSource.java:187) at com.google.android.gms.internal.firebase_messaging.zzk.zza + 4(zzk.java:4) at com.google.firebase.messaging.zzd.close + 37(zzd.java:37) at com.google.firebase.messaging.zzc.zzas + 51(zzc.java:51) at com.google.firebase.messaging.FirebaseMessagingService.zzd + 59(FirebaseMessagingService.java:59) at com.google.firebase.iid.zzb.run + 2(zzb.java:2) at java.util.concurrent.ThreadPoolExecutor.runWorker + 1112(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run + 587(ThreadPoolExecutor.java:587) at com.google.android.gms.common.util.concurrent.zza.run + 6(zza.java:6) at java.lang.Thread.run + 818(Thread.java:818)
This issue does not seem to follow the issue template. Make sure you provide all the required information.
implementation 'com.google.firebase:firebase-core:16.0.9' implementation 'com.google.firebase:firebase-messaging:18.0.0'
@Yonghejiunian sorry for my slow response here (I was on vacation) but can you give some more information on how to reproduce this issue?
Related: https://github.com/square/okio/issues/79
Still can't reproduce the issue, however our Crashlytics shows 4% crash sessions. All the session are in the background, different Android API and devices.

Same issue with; implementation 'com.google.firebase:firebase-core:17.1.0' implementation 'com.google.firebase:firebase-messaging:20.0.0'
Its happen only when you add image in notification Related issue https://github.com/firebase/firebase-android-sdk/issues/709
Hey @Yonghejiunian. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Can you give some more information on how to reproduce this issue?
Seems like any push notification from Firebase throws this. Also after dependencies update. The strange thing I do not receive fatal crash, notification works fine and received by service properly. So its encountered as crash on Crashlytics, but it does not fatal crash for the app.
Steps to reproduce for me:
- Install Firebase Messaging and Firebase Crashlytics.
- Send simple messsage or message with payload
- Watch crashlytics encounters this as fatal crash.
I filed issue https://github.com/firebase/firebase-android-sdk/issues/709 What's interesting is that I'm getting this error instead of the one I filed after reducing the image size to around 50KB with a width of 480px. Error:
Fatal Exception: java.lang.NullPointerException Attempt to read from field 'int com.android.okhttp.okio.Segment.limit' on a null object reference com.android.okhttp.okio.Buffer.write
Here's my stack trace:
com.android.okhttp.okio.Buffer.write (Buffer.java:1182)
com.android.okhttp.okio.Buffer.read (Buffer.java:1221)
com.android.okhttp.okio.RealBufferedSource.read (RealBufferedSource.java:55)
com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read (Http1xStream.java:393)
com.android.okhttp.internal.Util.skipAll (Util.java:159)
com.android.okhttp.internal.Util.discard (Util.java:141)
com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.close (Http1xStream.java:410)
com.android.okhttp.okio.RealBufferedSource.close (RealBufferedSource.java:396)
com.android.okhttp.okio.RealBufferedSource$1.close (RealBufferedSource.java:384)
com.google.android.gms.internal.firebase_messaging.zzk.zza (com.google.firebase:firebase-messaging@@20.0.0:4)
com.google.firebase.messaging.zzj.close (com.google.firebase:firebase-messaging@@20.0.0:38)
com.google.firebase.messaging.zzd.zza (com.google.firebase:firebase-messaging@@20.0.0:51)
com.google.firebase.messaging.FirebaseMessagingService.zzc (com.google.firebase:firebase-messaging@@20.0.0:60)
com.google.firebase.messaging.zze.run (com.google.firebase:firebase-messaging@@20.0.0:2)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
com.google.android.gms.common.util.concurrent.zza.run (Unknown Source:6)
java.lang.Thread.run (Thread.java:764)
What could be the issue?
I removed the image from notification, however still I got crash reports.
Hey @Yonghejiunian. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@Yonghejiunian if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Also getting this error using dependencies
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0
I am facing the same issue. I pin pointed the method that is giving error in firebase messaging library.
public final boolean zzb(Intent var1) {
if ("com.google.firebase.messaging.NOTIFICATION_OPEN".equals(var1.getAction())) {
PendingIntent var3;
if ((var3 = (PendingIntent)var1.getParcelableExtra("pending_intent")) != null) {
try {
var3.send();
} catch (CanceledException var4) {
Log.e("FirebaseMessaging", "Notification pending intent canceled");
}
}
if (MessagingAnalytics.shouldUploadMetrics(var1)) {
MessagingAnalytics.logNotificationOpen(var1);
}
return true;
} else {
return false;
}
}
What do you think is root cause? any ideas?
Same error for me
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0
Why is it closed? The issue isn't resolved!
Same error for me
implementation 'com.google.firebase:firebase-core:17.2.0' implementation 'com.google.firebase:firebase-messaging:20.0.0Why is it closed? The issue isn't resolved!
That's because nobody cares. My suggestion don't use images in notifications when you send them from Firebase console, instead send data messages using API and handle image loading by yourself
This is really sad that so many users faced the same issue but still we don’t have a solution. Firebase team should do something in future updates. For time being i will not use the images.
@ashwinraghav we're seeing this issue with customers of the Unity SDK as well https://github.com/firebase/quickstart-unity/issues/508 could you escalate?
Fatal Exception: java.lang.NullPointerException Attempt to read from field 'int com.android.okhttp.okio.Segment.limit' on a null object reference com.android.okhttp.okio.Buffer.write
Same issue. Couldn' find out what causes the problem. For my case just one phone (LG Premier Pro with Android 8) encountered with the crash
Facing similar issues in Android app (haveing firebase sdk). Sending notification in images via firebase console.
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int com.android.okhttp.okio.Segment.limit' on a null object reference at com.android.okhttp.okio.Buffer.write + 1182(Buffer.java:1182) at com.android.okhttp.okio.Buffer.read + 1221(Buffer.java:1221) at com.android.okhttp.okio.RealBufferedSource.read + 65(RealBufferedSource.java:65) at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read + 602(Http1xStream.java:602) at com.android.okhttp.internal.Util.skipAll + 172(Util.java:172) at com.android.okhttp.internal.Util.discard + 154(Util.java:154) at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.close + 619(Http1xStream.java:619) at com.android.okhttp.okio.RealBufferedSource.close + 421(RealBufferedSource.java:421) at com.android.okhttp.okio.RealBufferedSource$1.close + 409(RealBufferedSource.java:409) at com.google.android.gms.internal.firebase_messaging.zzk.a + 4(:4) at com.google.firebase.messaging.zzd.close + 37(:37) at com.google.firebase.messaging.zzc.a + 51(:51) at com.google.firebase.messaging.FirebaseMessagingService.c + 59(:59) at com.google.firebase.iid.zzb.run + 2(:2) at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641) at com.google.android.gms.common.util.concurrent.zza.run + 6(:6) at java.lang.Thread.run + 764(Thread.java:764)