We are using the package flutter_background_service and are seeing many reports in Firebase Crashlytics of this error:
Caused by java.lang.IllegalStateException
Not allowed to start service Intent
{ cmp=com.company.app/id.flutter.flutter_background_service.BackgroundService }:
app is in background uid UidRecord{18e0a38 u0a416 RCVR
idle change:uncached procs:1 proclist:20682, seq(0,0,0)}
I cannot seem to reproduce it on any devices I have (emulator, old/new physical Android devices)
It seems to be telling me that the service cannot be started when the app is in background mode, but we are attempting to start the service in main
, after WidgetsFlutterBinding.ensureInitialized();
, as per the docs.
Any pointer or suggestions would be much appreciated! Thanks.
OK so turns out that all the problems where with Android 11 and below.
Seems that flutter_background_service
is not compatible with these versions of Android and attempts to start the service in a way that causes a crash.
I thought I'd tested against these earlier versions of Android but clearly I had not!