It started to happen out of the blue a couple of months ago. Android 10 only.
After the user upgrades to a new version of our app, a crash happens on launch.
The crash is only observed once for a given user. So we think the crash happens right after the upgrade to the new build. It is the new build that crashes (not the old one).
This is an example of a crash.
Fatal Exception: android.app.RemoteServiceException: Bad notification(tag=null, id=30) posted from package yo.app,
crashing app(uid=10613, pid=16365):
Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #19 in yo.app:layout/sky_eraser_main:
Binary XML file line #19 in yo.app:layout/sky_eraser_main: Error inflating class androidx.appcompat.widget.Toolbar
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2052)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
The crashes look different from build to build. But the pattern is the same.
Let me transcribe what is happening in our opinion.
There is an ongoing notification (id=30) displaying the temperature (we are making a weather app). The notification is not able to post because of a crash while inflating its RemoteViews layout.
It seems that the original layout is substituted by another, completely unrelated layout (sky_eraser_main used in another place of our app). The wrong layout is different from build to build. It looks as though integer layout-ids are getting mixed up. Could it be the result of some weird R8 optimisation?
Unfortunately, we are not able to reproduce the crash locally.
Do you have an idea how to tackle these crashes?
The context
- Target SDK: 30
- Deployed as Android app bundle.
- minifyEnabled = true
- This is a kotlin multiplatform project.