Thanks everyone for your help.
I found this page:
https://issuetracker.google.com/issues/37103380 , which says that this error only happens on devices with Android 7, which is true in my case. Apparently this error was not displayed on earlier android versions but still present.
That put me on the right track. They say this error happens at
Activity.onSaveInstanceState(), so at
Activity_Pause in our case. I got an Android 7 device, so I did some tests and found out how to reproduce the problem.
In my app, I use xCustomListview, and when the number of items in the listview is more than 500 (edit: I think about 567 items), my app has this crash when going to pause (for example when I switch apps). I have tested and it's not because of the size of the list, but because of the listview. So I fixed the problem by limiting the number of items loaded in my Customlistview to maximum 500 items. That annoys me, but I don't have a choice at this stage. I should use the standard listview instead.
The issue is that there are no way to prevent this error, because it happens after the
Activity_Pause, and is not catchable in the IDE. The issue tracker says that this will not be fixed and works as intended.
Another suggested way to fix this problem, is to clear the scrollview before going to pause. Check the number of items in the scrollview, and if it's more than 500, clear it and reload at app_resume.