google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.75k stars 6.03k forks source link

Exoplayer WorkManager Extension is not compatible with Android 12 #9181

Closed seventhmoon closed 3 years ago

seventhmoon commented 3 years ago

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)

ojw28 commented 3 years ago

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

clhols commented 3 years ago

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)
clhols commented 3 years ago

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)
seventhmoon commented 3 years ago

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

seventhmoon commented 3 years ago

WorkManager 2.7.0-beta01is released.

https://developer.android.com/jetpack/androidx/releases/work#2.7.0-beta01

ojw28 commented 3 years ago

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.