Skip to content

Exoplayer WorkManager Extension is not compatible with Android 12 #9181

Closed

Description

@seventhmoon

There is a behavior change in Android 12 which requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent if the app is targeting Android 12.
Current stable version (2.5.0) of WorkManager don’t have these flags, and so it affects all apps directly, or indirectly using WorkManager.

Apps will throw the following exception in runtime

Fatal Exception: java.lang.IllegalArgumentException: com.sample.packagename: Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags(PendingIntent.java:386) at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:657) at android.app.PendingIntent.getBroadcast(PendingIntent.java:644) at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174) at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108) at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86) at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920)

Developer could manually adding the a compatible version of WorkManager (e.g. 2.7.0-alpha04) in their build.gradle file as workaround

implementation 'com.google.android.exoplayer:extension-workmanager:2.X.X'
// For apps targeting Android 12, add the following
constraints {
    implementation 'androidx.work:work-runtime:2.7.0-alpha04'
}

Issue is on current version of ExoPlayer WorkManager Extension (2.14.1)

Activity

  1. self-assigned this
    on Jul 13, 2021
  2. ojw28 commented on Jul 13, 2021

    @ojw28
    Contributor

    We will also update ExoPlayer to use 2.7.0 once it's stable.

  3. clhols commented on Jul 30, 2021

    @clhols

    Also an issue with the cast extension:

    Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
        Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
            at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
            at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
            at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
            at com.google.android.gms.cast.framework.media.internal.zzm.zza(com.google.android.gms:play-services-cast-framework@@19.0.0:46)
            at com.google.android.gms.cast.framework.CastSession$zza.onResult(com.google.android.gms:play-services-cast-framework@@19.0.0:11)
    
  4. clhols commented on Jul 30, 2021

    @clhols

    Forcing play-services-cast-framework:20.0.0 doesn't fix it:

    Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
        Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
            at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
            at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
            at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
            at com.google.android.gms.internal.cast.zzch.zzb(com.google.android.gms:play-services-cast@@20.0.0:1)
    
  5. seventhmoon commented on Aug 4, 2021

    @seventhmoon
    Author

    @clhols this is not related to this bug (Exoplayer WorkManager Extension).
    Have you submit the issue to issuetracker?

  6. seventhmoon commented on Sep 8, 2021

    @seventhmoon
    Author
  7. ojw28 commented on Oct 13, 2021

    @ojw28
    Contributor

    It should now be straightforward for applications to work around this problem by adding an explicit dependency on implementation 'androidx.work:work-runtime:2.7.0' in the application build.gradle. We will also be updating ExoPlayer's WorkManager extension to depend on this WorkManager release.

  8. locked and limited conversation to collaborators on Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions