How to fix android.view.InflateException: Error inflating class fragment

I got the error

E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.creatronix.levelup, PID: 17026
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.creatronix.levelup/de.creatronix.levelup.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment

after enabling minification in my build.

The issue is that with the usage of safeargs with custom objects we use the the @parcelize annotation which seems to be optimized away with R8

Fix

Add

-keepnames class * extends android.os.Parcelable

to your proguard-rules.pro file