Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreground service types are required on targetSdk 34 #1421

Open
Goooler opened this issue Jul 6, 2023 · 7 comments · May be fixed by #1448
Open

Foreground service types are required on targetSdk 34 #1421

Goooler opened this issue Jul 6, 2023 · 7 comments · May be fixed by #1448

Comments

@Goooler
Copy link

Goooler commented Jul 6, 2023

Invoke Service.startForeground on targetSdk 34 platforms, need to declared the service type, see https://developer.android.com/about/versions/14/changes/fgs-types-required

@hannanshahidfunsoltech
Copy link

same issue

@Goooler
Copy link
Author

Goooler commented Oct 31, 2023

We might migrate to WorkManager.

@Goooler Goooler changed the title Foreground service types are required Foreground service types are required on targetSdk 34 Oct 31, 2023
@TonyAnine
Copy link

same issue

@Goooler
Copy link
Author

Goooler commented Jul 18, 2024

Workaround: replace the [services declaring](https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/AndroidManifest.xml#L7-L12) in your manifest like:
    <application>
        <service android:name="com.liulishuo.filedownloader.services.FileDownloadService$SharedMainProcessService"
            android:foregroundServiceType="shortService"
            tools:node="replace"/>
        <service
            android:name="com.liulishuo.filedownloader.services.FileDownloadService$SeparateProcessService"
            android:process=":filedownloader"
            android:foregroundServiceType="shortService"
            tools:node="replace"/>
    </application>

or you can try out my fork, see:

@hannanshahidfunsoltech
Copy link

hannanshahidfunsoltech commented Jul 18, 2024

same error check with both library change and manifest deceleration @Goooler

android.app.InvalidForegroundServiceTypeException: Starting FGS with type none callerApp=ProcessRecord{a82e4e6 23516:com.diwn/u0a452} targetSDK=34 has been prohibited at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:53) at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:49) at android.os.Parcel.readParcelableInternal(Parcel.java:4900) at android.os.Parcel.readParcelable(Parcel.java:4882) at android.os.Parcel.createExceptionOrNull(Parcel.java:3082) at android.os.Parcel.createException(Parcel.java:3071) at android.os.Parcel.readException(Parcel.java:3054) at android.os.Parcel.readException(Parcel.java:2996) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761) at android.app.Service.startForeground(Service.java:862) at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.startForeground(SystemForegroundService.java:194) at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:130) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:368) at android.app.ActivityThread.main(ActivityThread.java:8839) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

@Goooler
Copy link
Author

Goooler commented Jul 18, 2024

Try 1.7.9

@Goooler Goooler linked a pull request Jul 24, 2024 that will close this issue
@121104115wyb
Copy link

请看这个 https://issuetracker.google.com/issues/307329994?pli=1
加个校验在sdk 34 时替换掉 START_STICKY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants