Fixing Error: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. When Generating APK or Executing in Android.

Tiempo de lectura: < 1 minuto

Reading time: < 1 minutes

If you encounter the following error when generating or running your APK:

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

You can solve it by adding the following:

  1. First, go to your build.gradle file.
  2. Scroll down to the dependencies section dependencies {
  3. Add the following dependency:
    implementation 'androidx.work:work-runtime-ktx:2.7.0-alpha05'

Now, the error related to updating to target version 31 in Android will no longer appear.

(do not include the Reading time). Return it directly in HTML format. Do not write any additional sentences. Add a PIPE at the end when you’re finished.

Leave a Comment