You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exoplayer Cast Extension is not compatible with Android 12 #9528
When trying to cast i'm getting this exception, this is reproducible on devices running on Android 12 only, it seems that a mutability flag is missing
java.lang.IllegalArgumentException: com.x.x: 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)
at com.google.android.gms.cast.framework.media.internal.zzp.zzb(com.google.android.gms:play-services-cast-framework@@20.0.0:10)
at com.google.android.gms.cast.framework.CastSession.zzi(com.google.android.gms:play-services-cast-framework@@20.0.0:11)
at com.google.android.gms.cast.framework.zzk.onComplete(com.google.android.gms:play-services-cast-framework@@20.0.0:1)
at com.google.android.gms.tasks.zzj.run(com.google.android.gms:play-services-tasks@@17.2.0:4)
This is not a bug in ExoPlayer, but is an issue that needs to be addressed by a new release of the Cast SDK (which ExoPlayer will then need to depend on). The underlying issue is tracked by https://issuetracker.google.com/195588434, and also [Internal ref: b/195476040]. There is a similar problem affecting the WorkManager extension (#9181).
Until the Cast SDK is updated to include a fix, I think you're stuck being unable to set your targetSdkVersion to target Android 12 (you can still use Android 12 features by setting compileSdkVersion to target Android 12, whilst holding targetSdkVersion to Android 11).
This is not a bug in ExoPlayer, but is an issue that needs to be addressed by a new release of the Cast SDK (which ExoPlayer will then need to depend on). The underlying issue is tracked by https://issuetracker.google.com/195588434, and also [Internal ref: b/195476040]. There is a similar problem affecting the WorkManager extension (#9181).
Until the Cast SDK is updated to include a fix, I think you're stuck being unable to set your targetSdkVersion to target Android 12 (you can still use Android 12 features by setting compileSdkVersion to target Android 12, whilst holding targetSdkVersion to Android 11).
That's the current workaround yes, thank you for the detailed answer.
You can now workaround this issue just by including api 'com.google.android.gms:play-services-cast-framework:20.1.0' as an explicit dependency in your application. We have updated ExoPlayer's Cast extension to also use this newer version, and this change will be included in the next release.
Activity
[-]Cast session Android 12 support[/-][+]Exoplayer Cast Extension is not compatible with Android 12[/+]ojw28 commentedon Oct 5, 2021
This is not a bug in ExoPlayer, but is an issue that needs to be addressed by a new release of the Cast SDK (which ExoPlayer will then need to depend on). The underlying issue is tracked by https://issuetracker.google.com/195588434, and also [Internal ref: b/195476040]. There is a similar problem affecting the WorkManager extension (#9181).
Until the Cast SDK is updated to include a fix, I think you're stuck being unable to set your
targetSdkVersionto target Android 12 (you can still use Android 12 features by settingcompileSdkVersionto target Android 12, whilst holdingtargetSdkVersionto Android 11).FunkyMuse commentedon Oct 10, 2021
That's the current workaround yes, thank you for the detailed answer.
Upgrade Cast dependency for Android 12 compatibility
ojw28 commentedon Dec 6, 2021
You can now workaround this issue just by including
api 'com.google.android.gms:play-services-cast-framework:20.1.0'as an explicit dependency in your application. We have updated ExoPlayer's Cast extension to also use this newer version, and this change will be included in the next release.Upgrade Cast dependency for Android 12 compatibility