mercredi 28 janvier 2015

Handling and Mitigating IllegalStateException ("failure saving state: active $Fragment has cleared index: -1")


Vote count:

0




My Android application manages multiple fragments. I am seeing a large number crashes in the field, however, containing this log line:



java.lang.IllegalStateException: Failure saving state: active XxxFragment{81e598 id=0x7f0b0069 tag_yyy} has cleared index: -1



Searches of answers in Stack Overflow have been fruitless; I seem to have a lot of company in wondering exactly what this exception means. Digging into the exception trace and Android sources, I can see that the exception is coming from the point at which my main Activity is saving its state, and the individual Fragments are being written into a Parcelable. Each Fragment has an index (called mIndex) which must be nonnegative, but it's not really clear from the code why that must be the case, as mIndex is never used again in that function.


I have no good idea how the Fragment gets into this state, or what I can do about it. I have been unable to reproduce the error in my own test environment. Can anyone shed any light on how to avoid and/or deal with this exception?


java.lang.IllegalStateException: Failure saving state: active has cleared index in fragment


What does active fragment has cleared index: -1 mean and how do I fix it?


Getting exception as Failure saving state: active Fragment has cleared index: -1 when I am pressing home button of android device


IllegalStateException with Android Fragments



asked 44 secs ago







Handling and Mitigating IllegalStateException ("failure saving state: active $Fragment has cleared index: -1")

Aucun commentaire:

Enregistrer un commentaire