0

I'm currently using Android Arch Navigation (1.0.0-alpha06) in one of my projects. But from time to time I'm getting the same crash in my Crashlytics:

java.lang.RuntimeException: Unable to start activity ComponentInfo{*.*.*.MainActivity}: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@1e9584c: Unmarshalling unknown type code 7274595 at offset 516

So after digging why I was having multiple crashes on my MainActivity I set my device to don't keep activities (developer options). And Bam! every time I send my app to the background and come back the app crashes.

I don't have anything set on onSaveInstanceState/onRestoreInstanceState methods. So I don't know where to look at.

This happens with or without proguard enabled (I test it with both debug and release version), so I can rule out a missing proguard rule.

Other info that could help: My app is using android.arch libraries (MVVM).

Edit: I don't have access to the fragment manager perse, the Navigation Library is the one in charge of the fragments, so any other error regarding fragments inflation is not related

vicmns
  • 664
  • 1
  • 8
  • 19
  • 1
    Possible duplicate of [Error inflating class fragment](https://stackoverflow.com/questions/6424853/error-inflating-class-fragment) – TheWanderer Oct 24 '18 at 23:55
  • Do you have any classes that implement Parcelable in your app? – Ben P. Nov 02 '18 at 18:46
  • I have a couple of Data Class that uses Kotlin Parcelize; but I'm not using them in `onSaveInstanceState/onRestoreInstanceState`. The crash happens even when I removed those methods from my main activity and fragments... – vicmns Nov 02 '18 at 23:21

2 Answers2

0

OK I finally found the reason of the crash... It was one custom View Library that I was using that I wasn't managing correctly it's own Instance restore logic.

I found out that the crash was only happening in only two sections of the app, that pin point me where could be the problem.

In the end it was more a problem of not having a good stack trace to look where the problem arisen...

vicmns
  • 664
  • 1
  • 8
  • 19
-2

Keep in mind Android will still do some save instance state work unless you override the methods in your activities and fragments to do nothing.

  @Override
  protected void onSaveInstanceState(Bundle outState) {
    // don't restore state
  }

In many cases we do this due to the many strange errors otherwise. The implication is that if your app is ejected from memory, it will 100% start fresh the next time it is accessed.

Jeffrey Blattman
  • 21,054
  • 8
  • 74
  • 127