Skip to content

App crash on startup in A14+ with casting #2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
CranberrySoup opened this issue Feb 21, 2025 · 3 comments
Closed
1 task

App crash on startup in A14+ with casting #2178

CranberrySoup opened this issue Feb 21, 2025 · 3 comments
Assignees

Comments

@CranberrySoup
Copy link

CranberrySoup commented Feb 21, 2025

Version

Media3 pre-release (alpha, beta or RC not in this list)

More version details

This issue affects both 1.6.0-alpha03 and 1.5.1 (latest alpha and stable as of writing).
Also tested on 4c3ac818 (latest commit 5 hours ago as of this writing)

Devices that reproduce the issue

Any android device with android version 14 and above with google play services installed, but play services are disabled.

I am able to reproduce the issue on the stock android studio emulator with play services running sdk 35.

The app using the cast library needs to target sdk 34+.

Devices that do not reproduce the issue

  • Devices below android 14
  • Devices with play services enabled
  • Devices completely without play services (AOSP emulator).
  • Any app not targeting sdk 34+.

Reproducible in the demo app?

Yes

Reproduction steps

Example:

  1. Use Android Emulator on android 15 with play services installed
  2. Disable play services in app settings
  3. Open the demo-cast app
  4. It instantly crashes

Expected result

The lack of play services should gracefully fail like in older android versions.
In the demo app the app should not crash and instead just show "Failed to get Cast Context. Try updating Google Play Services and restart the app" as it does on sdk < 34 with play services disabled.

Actual result

App crashes with the following stack trace:

Process: androidx.media3.demo.cast, PID: 6441
java.lang.IllegalArgumentException: androidx.media3.demo.cast: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
  at android.os.Parcel.createExceptionOrNull(Parcel.java:3246)
  at android.os.Parcel.createException(Parcel.java:3226)
  at android.os.Parcel.readException(Parcel.java:3209)
  at android.os.Parcel.readException(Parcel.java:3151)
  at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:7000)
  at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:579)
  at android.app.PendingIntent.getActivity(PendingIntent.java:560)
  at android.app.PendingIntent.getActivity(PendingIntent.java:524)
  at com.google.android.gms.internal.common.zzd.zza(com.google.android.gms:play-services-basement@@18.0.0:1)
  at com.google.android.gms.common.GoogleApiAvailabilityLight.getErrorResolutionPendingIntent(com.google.android.gms:play-services-basement@@18.0.0:3)
  at com.google.android.gms.common.GoogleApiAvailabilityLight.getErrorResolutionPendingIntent(com.google.android.gms:play-services-basement@@18.0.0:1)
  at com.google.android.gms.common.GoogleApiAvailability.getErrorResolutionPendingIntent(com.google.android.gms:play-services-base@@18.0.1:1)
  at com.google.android.gms.common.GoogleApiAvailability.getErrorResolutionPendingIntent(com.google.android.gms:play-services-base@@18.0.1:4)
  at com.google.android.gms.common.GoogleApiAvailability.zah(com.google.android.gms:play-services-base@@18.0.1:2)
  at com.google.android.gms.common.api.internal.GoogleApiManager.zaG(com.google.android.gms:play-services-base@@18.0.1:1)
  at com.google.android.gms.common.api.internal.zabq.zar(com.google.android.gms:play-services-base@@18.0.1:21)
  at com.google.android.gms.common.api.internal.zabq.zao(com.google.android.gms:play-services-base@@18.0.1:13)
  at com.google.android.gms.common.api.internal.zabq.zap(com.google.android.gms:play-services-base@@18.0.1:8)
  at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(com.google.android.gms:play-services-base@@18.0.1:64)
  at android.os.Handler.dispatchMessage(Handler.java:103)
  at android.os.Looper.loopOnce(Looper.java:232)
  at android.os.Looper.loop(Looper.java:317)
  at android.os.HandlerThread.run(HandlerThread.java:85)
  Caused by: android.os.RemoteException: Remote stack trace:
  at com.android.server.am.ActivityManagerService.getIntentSenderWithFeatureAsApp(ActivityManagerService.java:5584)
  at com.android.server.am.ActivityManagerService.getIntentSenderWithFeature(ActivityManagerService.java:5526)
  at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3460)
  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2812)
  at android.os.Binder.execTransactInternal(Binder.java:1500)

Media

Not applicable.

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@CranberrySoup
Copy link
Author

I think this may be solved by simply updating the cast dependency, but this cannot be done on the app-side.

@icbaker
Copy link
Collaborator

icbaker commented Feb 25, 2025

I think this may be solved by simply updating the cast dependency, but this cannot be done on the app-side.

This should be possible on the app side. If you're using gradle, you can use a dependency constraint when building your app: https://docs.gradle.org/current/userguide/dependency_constraints.html

@icbaker
Copy link
Collaborator

icbaker commented Feb 25, 2025

I can reproduce the issue using the steps described. It is indeed fixed by bumping the cast dependency to com.google.android.gms:play-services-cast-framework:21.5.0 (from 21.3.0. 21.4.0 still crashed).

I'll send a change for this version bump internally, but as described above you should be able to solve this on the app side without waiting for a library update.

copybara-service bot pushed a commit that referenced this issue Feb 25, 2025
This resolves an app crash on devices with Google Play Services
installed but disabled due to `FLAG_MUTABLE` on a `PendingIntent`.

Issue: #2178

#cherrypick

PiperOrigin-RevId: 730885329
@icbaker icbaker closed this as completed Feb 25, 2025
oceanjules pushed a commit that referenced this issue Mar 3, 2025
This resolves an app crash on devices with Google Play Services
installed but disabled due to `FLAG_MUTABLE` on a `PendingIntent`.

Issue: #2178

#cherrypick

PiperOrigin-RevId: 730885329
(cherry picked from commit c4eef60)
@androidx androidx locked and limited conversation to collaborators Apr 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants