Skip to content

Force Close App when start foreground with Android compileSdkVersion 31 #23

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

Closed
pram507 opened this issue Nov 12, 2021 · 2 comments
Closed

Comments

@pram507
Copy link

pram507 commented Nov 12, 2021

Force Close When Start Foreground with Android compileSdkVersion 31

hi i got force close when start the foreground service running on android emulator version Sv2
can u fix it.

Script

FlutterForegroundTask.init(
androidNotificationOptions: const AndroidNotificationOptions(
channelId: 'notification_channel_id',
channelName: 'Foreground Notification',
channelDescription: 'This notification appears when the foreground service is running.',
channelImportance: NotificationChannelImportance.LOW,
priority: NotificationPriority.LOW,
iconData: NotificationIconData(
resType: ResourceType.mipmap,
resPrefix: ResourcePrefix.ic,
name: 'launcher',
),
),
iosNotificationOptions: const IOSNotificationOptions(
showNotification: true,
playSound: false,
),
foregroundTaskOptions: const ForegroundTaskOptions(
interval: 5000,
autoRunOnBoot: true,
),
printDevLog: true,
);

Android Log.

D/CompatibilityChangeReporter( 7017): Compat change id reported: 160794467; UID 10151; state: ENABLED
D/AndroidRuntime( 7017): Shutting down VM
E/AndroidRuntime( 7017): FATAL EXCEPTION: main
E/AndroidRuntime( 7017): Process: com.pramana507.cyclops_droid.dev, PID: 7017
E/AndroidRuntime( 7017): java.lang.RuntimeException: Unable to create service com.pravera.flutter_foreground_task.service.ForegroundService: java.lang.IllegalArgumentException: com.pramana507.cyclops_droid.dev: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime( 7017): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-ID)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.2)
[✓] Connected device (2 available)

@Dev-hwang
Copy link
Owner

@pram507

Please update this plugin to 3.2.3 and try again.

dependencies:
  flutter_foreground_task: ^3.2.3

@pram507
Copy link
Author

pram507 commented Nov 13, 2021

nice close the issue, working now on android sdk 31, thank u

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

No branches or pull requests

2 participants