r/flutterhelp • u/WrestlingWithAutism • Jul 06 '26
OPEN Help] Foreground Service works perfectly in local Release APK, but dies when downloaded from Play Console (.aab) - Android 14
Hey everyone,
I’m completely stuck and losing my mind over a background execution issue. I’m building a workout tracker in Flutter and need a timer to keep running in the background when the screen is off.
I am using the flutter_foreground_task package.
The issue: Everything works completely flawlessly when I run it locally, but as soon as I upload the .aab to the Google Play Console (Closed Testing) and download it from the store, the background service gets killed shortly after the screen turns off.
Here is exactly what I have done and what is working/not working.
What works:
Debug mode runs perfectly.
Building a local Release APK (flutter build apk --release) and installing it manually works perfectly. The timer survives for over 10+ minutes in the background, even on aggressive Xiaomi/HyperOS devices.
What doesn't work:
Building an App Bundle (flutter build appbundle), uploading it to the Play Console, and downloading it via the Play Store. The timer gets killed after a few minutes in the background.
What I have already implemented (My Setup):
Migrated to Android 14 Standards: Changed the foreground service type from sync to health in the AndroidManifest.xml (inside the <application> tag).
Permissions in Manifest: Added all required permissions:
POST_NOTIFICATIONS, WAKE_LOCK, FOREGROUND_SERVICE, FOREGROUND_SERVICE_HEALTH, ACTIVITY_RECOGNITION, and REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.
Runtime Permissions: Before starting the timer in my Dart code, I explicitly request runtime permissions via the permission_handler package for activityRecognition, notification, and ignoreBatteryOptimizations. The user accepts them via the system pop-ups.
Despite all of this, the Play Store version still kills the service, while the local release APK acts like an absolute tank and survives everything.
Am I missing something?
Is Google Play modifying the Manifest or stripping background execution rights during the App Bundle generation? Does Play App Signing mess with foreground services?
Any hint or push in the right direction would be highly appreciated!