ekasetiawans / flutter_background_service

269 stars 188 forks source link

Android 12 - App Crash #471

Open BBUBBA opened 2 months ago

BBUBBA commented 2 months ago

WatchdogReceiver.java

// Check is background service every 5 seconds
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
//Android 13 (SDK 33) requires apps to declare android.permission.SCHEDULE_EXACT_ALARM to use setExact <- Old
// Check is background service every 5 seconds
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
//Android 12 (SDK 31) requires apps to declare android.permission.SCHEDULE_EXACT_ALARM to use setExact <- Change.

Thank you !!!!!!!!

micodev commented 2 months ago

what is this ?

BBUBBA commented 2 months ago

Error starting service on Android 12.

It works when modified as an example.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(100, Failed while read arguments, Caller com.call needs to hold android.permission.SCHEDULE_EXACT_ALARM to set exact alarms., null)
#0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:170:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
<asynchronous suspension>
#2      FlutterBackgroundServiceAndroid.start (package:flutter_background_service_android/flutter_background_service_android.dart:59:20)
<asynchronous suspension>
#3      MobileService.startService (package:clientcore/Services/mobile/MobileService.dart:25:14)
<asynchronous suspension>
RizwanAhmed11 commented 2 months ago

I also have the same issue only on Android 12