aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.02k stars 549 forks source link

Android:startForegroundService TransferService is crashing in API 33. #3322

Closed ajayakrishnan closed 1 year ago

ajayakrishnan commented 1 year ago

Describe the bug Calling startForegroundService with TransferService is crashing in API 33 when the app is removed from background.

Fatal Exception: java.lang.RuntimeException: Unable to create application com.test.application.TestApplication: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service TransferService at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7619) at android.app.ActivityThread.-$$Nest$mhandleBindApplication() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

To Reproduce

  1. Open the app
  2. Put the app in the background.
  3. Clear from memory.
  4. App crashes.

**Environment Information

gpanshu commented 1 year ago

Hi @ajayakrishnan whats your compilesdkversion and targetsdkversion?

tylerjroach commented 1 year ago

@ajayakrishnan Please update to the newest version of the SDK. There were changes in the way that the storage foreground service is started/stopped between the version you are using and the latest. If you are still seeing crashes with the latest version, please let us know.