I created an update for an app (which uses a foreground service) in the Google Play Store and uploaded it there as an internal test track. The targetSdkVersion is 34 (Android 14). I get the following error message (crash) from the Google Pre-Launch Report for a Pixel 7 Pro (Android 14) and a test device with Android 13:
android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException
Exception android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{e4878b2 u0 appinventor.ai_bodymindpower.AT_klassisch/de.ullisroboterseite.ursai2medianotification.ForegroundService c:appinventor.ai_bodymindpower.AT_klassisch}
at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException (ActivityThread.java:2243)
at android.app.ActivityThread.throwRemoteServiceException (ActivityThread.java:2214)
at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2520)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loopOnce (Looper.java:232)
at android.os.Looper.loop (Looper.java:317)
at android.app.ActivityThread.main (ActivityThread.java:8592)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:878)
Hmm, I have been using the extension for years without any problems. I have already discussed the problem with Ulli. He said that the problem should not occur and in fact it does not occur on real devices. However, it does appear in the Pre-launch report environment for whatever reason.
These kinds of scenarios happen when a part of code might fail unexpectedly but does not affect the main thread. Thus the extension never gets to start a foreground service (within x seconds as required by system)
These can also sometimes be unexpected and rare, considering how diverse Android ecosystem is. (Behavior wise)
It could be something that happens only under Google's test environment.
A loop checking the existence of any of these properties and generating a timely temporal delay if it does not exist, so as to give time for the extension to be completely loaded or the service in the foreground is ready, would not solve the problem?