Search code examples
androidandroid-architecture-componentsandroid-architecture-navigation

Android Navigation Architecture: crash while on Don't keep Activities option


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


Solution

  • 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...