Skip to content

🐞Exception: expedited work (setExpedited) requires the 'android.permission.FOREGROUND_SERVICE_SHORT_SERVICE' #731

Description

@absar
  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.10.7
workmanager_android 0.10.6

Describe the error
Getting below exception even though not changing the default permission included by the plugin

Workmanager().registerOneOffTask(
  Jobs.manualBackupJob.code,
  Jobs.manualBackupJob.code,
  existingWorkPolicy: ExistingWorkPolicy.replace,
  outOfQuotaPolicy: OutOfQuotaPolicy.runAsNonExpeditedWorkRequest,
  expedited: true,
);

You can also reproduce this with example app by pressing Register expedited task (Android)

The merged manifest contains both FOREGROUND_SERVICE, FOREGROUND_SERVICE_SHORT_SERVICE

manually declaring these in AndroidManifest.xml does not help either:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SHORT_SERVICE"/>
PlatformException(IllegalStateException, java.lang.IllegalStateException: workmanager_android: expedited work (setExpedited) requires the 'android.permission.FOREGROUND_SERVICE_SHORT_SERVICE' permission in the merged manifest, but it is missing. FOREGROUND_SERVICE_SHORT_SERVICE is declared by the plugin by default; keep it if you use expedited work (see the workmanager_android README, issue #725)., Cause: null, Stacktrace: java.lang.IllegalStateException: workmanager_android: expedited work (setExpedited) requires the 'android.permission.FOREGROUND_SERVICE_SHORT_SERVICE' permission in the merged manifest, but it is missing. FOREGROUND_SERVICE_SHORT_SERVICE is declared by the plugin by default; keep it if you use expedited work (see the workmanager_android README, issue #725).
	at dev.fluttercommunity.workmanager.ForegroundServiceUtilsKt.requireForegroundServicePermission(ForegroundServiceUtils.kt:94)
	at dev.fluttercommunity.workmanager.WorkManagerWrapper.enqueueOneOffTask(WorkManagerUtils.kt:249)
	at dev.fluttercommunity.workmanager.WorkmanagerPlugin.registerOneOffTask(WorkmanagerPlugin.kt:117)
	at dev.fluttercommunity.workmanager.pigeon.WorkmanagerHostApi$Companion.setUp$lambda$1$0(WorkmanagerApi.g.kt:1348)
	at dev.fluttercommunity.workmanager.pigeon.WorkmanagerHostApi$Companion.$r8$lambda$KtgWH6mupWa5ZY-MZRTaLrCQNDA(Unknown Source:0)
	at dev.fluttercommunity.workmanager.pigeon.WorkmanagerHostApi$Companion$$ExternalSyntheticLambda1.onMessage(D8$$SyntheticClass:0)
	at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:286)
	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:313)
	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at android.os.Handler.handleCallback(Handler.java:995)
	at android.os.Handler.dispatchMessage(Handler.java:103)
	at android.os.Looper.loopOnce(Looper.java:248)
	at android.os.Looper.loop(Looper.java:338)
	at android.app.ActivityThread.main(ActivityThread.java:9067)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
, null)

#0   _extractReplyValueOrThrow (package:workmanager_platform_interface/src/pigeon/workmanager_api.g.dart:26:5)
#1   WorkmanagerHostApi.registerOneOffTask (package:workmanager_platform_interface/src/pigeon/workmanager_api.g.dart:1182:5)
#2   <asynchronous suspension>
#3   WorkmanagerAndroid.registerOneOffTask (package:workmanager_android/workmanager_android.dart:46:5)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions