RuleIn force

Foreground service types

Apps targeting Android 14 (API 34) or higher must declare a type and the matching permission for every foreground service, or the app crashes when the service starts.

Apps targeting API 34 and higher

What the rule is

Every foreground <service> needs android:foregroundServiceType plus the matching FOREGROUND_SERVICE_<TYPE> permission. Without them the app crashes at runtime with MissingForegroundServiceTypeException or SecurityException.

Google Play also asks for a foreground service declaration in Play Console, under App content.

Apps targeting Android 15 (API 35) get a time limit of 6 hours in 24 hours for dataSync and mediaProcessing services, and BOOT_COMPLETED receivers can no longer start some foreground service types.

Who it affects

Apps that run foreground services, including services added by SDKs you ship, such as media playback, location, sync or upload libraries.

How to fix it

  1. Add android:foregroundServiceType to every foreground service in your merged manifest.
  2. Declare the matching FOREGROUND_SERVICE_<TYPE> permission for each type.
  3. For specialUse, add the PROPERTY_SPECIAL_USE_FGS_SUBTYPE property explaining the use.
  4. Fill in the foreground service declaration in Play Console.
  5. For dataSync and mediaProcessing, handle Service.onTimeout and stop the service, or move the work to WorkManager.

Check your app

Run this in your Android project. It checks this rule on your machine, and nothing about your project is uploaded.

npx play-preflight check --only foreground-services

Official source