novoda / download-manager

A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures
Apache License 2.0
483 stars 63 forks source link

TargetSDK 34 cause Fatal exception: MissingForegroundServiceTypeException #537

Closed kaan-celen closed 1 month ago

kaan-celen commented 6 months ago

Hey Dear Novoda,

We are using 2.3.4 version of this library and we update our targetSDK version to 34 recently. After that we start to receive following crash on Android 14 devices. Can you help us or do you consider to update the library?

FATAL EXCEPTION: main
Process: com.channel4.ondemand, PID: 6982
android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{ba76ee8 6982:com.channel4.ondemand/u0a320} targetSDK=34
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
    at android.os.Parcel.readParcelableInternal(Parcel.java:5015)
    at android.os.Parcel.readParcelable(Parcel.java:4997)
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3177)
    at android.os.Parcel.createException(Parcel.java:3166)
    at android.os.Parcel.readException(Parcel.java:3149)
    at android.os.Parcel.readException(Parcel.java:3091)
    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6861)
    at java.lang.reflect.Method.invoke(Native Method)
    at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy4.setServiceForeground(Unknown Source)
    at android.app.Service.startForeground(Service.java:775)
    at com.novoda.downloadmanager.LiteDownloadService.start(LiteDownloadService.java:43)
    at com.novoda.downloadmanager.ServiceNotificationDispatcher.updatePersistentNotification(ServiceNotificationDispatcher.java:77)
    at com.novoda.downloadmanager.ServiceNotificationDispatcher.lambda$executeUpdateNotification$0$com-novoda-downloadmanager-ServiceNotificationDispatcher(ServiceNotificationDispat
    at com.novoda.downloadmanager.ServiceNotificationDispatcher$$ExternalSyntheticLambda0.performAction(Unknown Source:4)
    at com.novoda.downloadmanager.Wait$ThenPerform.thenPerform(Wait.java:46)
    at com.novoda.downloadmanager.ServiceNotificationDispatcher.updateNotification(ServiceNotificationDispatcher.java:32)
    at com.novoda.downloadmanager.DownloadBatchStatusNotificationDispatcher.updateNotification(DownloadBatchStatusNotificationDispatcher.java:44)
    at com.novoda.downloadmanager.LiteDownloadManagerDownloader.lambda$downloadBatchCallback$1$com-novoda-downloadmanager-LiteDownloadManagerDownloader(LiteDownloadManagerDownloader
    at com.novoda.downloadmanager.LiteDownloadManagerDownloader$$ExternalSyntheticLambda3.run(Unknown Source:8)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8501)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
kaan-celen commented 1 month ago

I fork it, fix the issue then release 2.3.5 on github. FYI https://github.com/kaan-celen/download-manager