FLAG_IMMUTABLE or FLAG_MUTABLE 🤖 Android

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

Apps targeting Android 12+ must declare PendingIntent mutability; missing flags crash.

Seen on: Android

Meaning

Add PendingIntent.FLAG_IMMUTABLE for most cases (notifications, alarms). Use FLAG_MUTABLE only when the system must fill in extras (inline reply, bubbles). Old libraries (WorkManager < 2.7, old Firebase/Play Services) also crash — update them.

Common causes

  • PendingIntent created without mutability flag
  • Outdated library creating PendingIntents (WorkManager, analytics SDKs)

⚡ Quick fix

  1. Add FLAG_IMMUTABLE (or FLAG_MUTABLE when required)
  2. Update WorkManager/Firebase/Play Services libraries

Detailed fix by platform

Kotlin

  1. val pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)

How to diagnose

  1. Caller — Your code or a dependency?
  2. Versions — WorkManager ≥ 2.7?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.