Skip to content

Fix Missing DynamiteApplicationContext after GmsCore package rename#290

Open
zappybiby wants to merge 2 commits intoReVanced:mainfrom
zappybiby:fix/gmscore-aa-compat-2026-02-pr
Open

Fix Missing DynamiteApplicationContext after GmsCore package rename#290
zappybiby wants to merge 2 commits intoReVanced:mainfrom
zappybiby:fix/gmscore-aa-compat-2026-02-pr

Conversation

@zappybiby
Copy link

@zappybiby zappybiby commented Feb 19, 2026

Summary

This PR addresses an Android Auto crash loop when connecting to ReVanced YouTube Music.

During Android Auto media binding, YouTube Music repeatedly crashes with:
java.lang.IllegalStateException: Missing DynamiteApplicationContext.

The failure occurs in the GmsCore Dynamite googlecertificates path and breaks Android Auto media integration (spinner / no controls / no artwork), while playback may still continue.

Problem

When Android Auto binds com.google.android.apps.youtube.music.mediabrowser.MusicBrowserService, the app crashes in this chain:

  • com.google.android.gms.common.GoogleCertificatesImpl
  • java.lang.IllegalStateException: Missing DynamiteApplicationContext
  • com.google.android.apps.youtube.music.mediabrowser.MusicBrowserService.e(PG:137)

Android Auto then loses the media browser connection and repeatedly retries/restarts the service.

Regression source

The regression was introduced by the package rename work:

  • e6cd2487 (same logical change also appears as c778936c):
    feat: Allow side-by-side installation with Google services by renaming permissions and authorities

What changed in that commit

  • play-services-core/build.gradle:122
    • applicationId = "app.revanced.android.gms"
  • play-services-core/build.gradle:134
    • resValue "string", "package_id", "app.revanced.android.gms"

Why this caused the crash

After that rename, some runtime code paths still resolved remote/dynamite context using only the old package assumption (com.google.android.gms), which can produce an invalid module context under renamed GmsCore.

Pre-fix examples:

  • play-services-core/src/main/java/com/google/android/gms/chimera/DynamiteContextFactory.java (pre-fix line 52)
    • originalContext.createPackageContext(Constants.GMS_PACKAGE_NAME, 0);
  • play-services-base/src/main/java/com/google/android/gms/common/GooglePlayServicesUtil.java (pre-fix lines 140, 153)
    • createPackageContext(Constants.GMS_PACKAGE_NAME, ...)
    • getResourcesForApplication(Constants.GMS_PACKAGE_NAME)

When Android Auto triggers YT Music media-browser startup, this mismatch appears in the googlecertificates Dynamite path and terminates with:

  • java.lang.IllegalStateException: Missing DynamiteApplicationContext.

Environment

Component Value
Device Samsung SM-S926U (e2q)
Android 16 (SDK 36)
Security patch 2026-01-01
Build fingerprint samsung/e2qsqw/e2q:16/BP2A.250605.031.A3/S926USQS4CZA1:user/release-keys
Android Auto com.google.android.projection.gearhead 16.1.660414-release (versionCode=161660414)
ReVanced YouTube Music 8.10.52 (versionCode=81052240)
ReVanced GmsCore 0.3.13.2.250932 (versionCode=250932004)
Bugreport capture 2026-02-18 20:34:18

Evidence

1) Crash loop in YT Music media browser startup

02-18 20:34:08.658 E AndroidRuntime: FATAL EXCEPTION: main
02-18 20:34:08.658 E AndroidRuntime: Process: app.revanced.android.apps.youtube.music, PID: 20756
02-18 20:34:08.658 E AndroidRuntime: java.lang.IllegalStateException: Missing DynamiteApplicationContext.
02-18 20:34:08.658 E AndroidRuntime: at com.google.android.gms.common.GoogleCertificatesImpl.a(...)
02-18 20:34:08.658 E AndroidRuntime: at com.google.android.apps.youtube.music.mediabrowser.MusicBrowserService.e(PG:137)
02-18 20:34:08.658 E AndroidRuntime: at android.service.media.MediaBrowserService$ServiceState.connectOnHandler(...)

02-18 20:33:51.884 W ActivityManager: Process app.revanced.android.apps.youtube.music has crashed too many times, killing! Reason: crashed quickly
Full stacktrace (raw)
02-18 20:34:08.502 10526 20756 20756 W DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
02-18 20:34:08.502 10526 20756 20756 W DynamiteModule: IDynamite loader version = 2, no high precision latency measurement.
02-18 20:34:08.502 10526 20756 20756 W DynamiteModule: IDynamite loader version = 2
02-18 20:34:08.502 10526 20756 20756 D GmsDynamiteLoaderImpl: createModuleContext for com.google.android.gms.googlecertificates at version 1
02-18 20:34:08.502 10526 20756 20756 D DynamiteContextFactory: Created and cached a new DynamiteContext for cacheKey: com.google.android.gms.googlecertificates-app.revanced.android.apps.youtube.music
02-18 20:34:08.502 10526 20756 20756 W s.youtube.music: Unsupported class loader: java.lang.Class<com.google.android.gms.chimera.container.FilteredClassLoader>

02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: FATAL EXCEPTION: main
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: Process: app.revanced.android.apps.youtube.music, PID: 20756
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: java.lang.IllegalStateException: Missing DynamiteApplicationContext.
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at com.google.android.gms.common.GoogleCertificatesImpl.a(:com.google.android.gms@260438035@26.04.38 (260400-867839860):10)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at com.google.android.gms.common.GoogleCertificatesImpl.<init>(:com.google.android.gms@260438035@26.04.38 (260400-867839860):4)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at java.lang.Class.newInstance(Native Method)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at sus.d(PG:11)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at sfx.d(PG:30)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at sgm.a(PG:32)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at sgm.c(PG:1)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at keh.g(PG:70)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at com.google.android.apps.youtube.music.mediabrowser.MusicBrowserService.e(PG:137)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at bof.onGetRoot(PG:119)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.service.media.MediaBrowserService$ServiceState.connectOnHandler(MediaBrowserService.java:784)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.service.media.MediaBrowserService$ServiceBinder.lambda$connect$0(MediaBrowserService.java:251)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.service.media.MediaBrowserService$ServiceBinder$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:995)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:103)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:273)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:363)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:10060)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
02-18 20:34:08.658 10526 20756 20756 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

02-18 20:33:51.010  1000  2558  3973 I am_crash: [19847,0,app.revanced.android.apps.youtube.music,553369156,java.lang.IllegalStateException,Missing DynamiteApplicationContext.,:com.google.android.gms@260438035@26.04.38 (260400-867839860),10,0]
02-18 20:33:51.883  1000  2558  6755 I am_crash: [20273,0,app.revanced.android.apps.youtube.music,551272004,java.lang.IllegalStateException,Missing DynamiteApplicationContext.,:com.google.android.gms@260438035@26.04.38 (260400-867839860),10,0]
02-18 20:34:08.661  1000  2558  6751 I am_crash: [20756,0,app.revanced.android.apps.youtube.music,551272004,java.lang.IllegalStateException,Missing DynamiteApplicationContext.,:com.google.android.gms@260438035@26.04.38 (260400-867839860),10,0]

02-18 20:33:51.884  1000  2558  6755 W ActivityManager: Process app.revanced.android.apps.youtube.music has crashed too many times, killing! Reason: crashed quickly

2) Dynamite googlecertificates context created immediately before crash

02-18 20:34:08.502 W DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
02-18 20:34:08.502 D GmsDynamiteLoaderImpl: createModuleContext for com.google.android.gms.googlecertificates at version 1
02-18 20:34:08.502 D DynamiteContextFactory: Created and cached a new DynamiteContext for cacheKey: com.google.android.gms.googlecertificates-app.revanced.android.apps.youtube.music

3) Android Auto is actively binding YT Music media service

Start proc ... app.revanced.android.apps.youtube.music ... for service .../MusicBrowserService
GH.MediaBCConnection: onConnectionSuspended component=.../MusicBrowserService
Scheduling restart of crashed service .../MusicBrowserService in 20000ms

4) Additional service/module warnings seen during the same window

Unable to start service Intent { act=com.google.android.gms.phenotype.service.START ... pkg=app.revanced.android.gms } U=0: not found
No such module known: com.google.android.gms.cast.framework.dynamite
returning temp fix module version for com.google.android.gms.cast.framework.dynamite. Cast API wil not be functional!

Proposed fixes in this PR

  1. d2ec2657 - fix(chimera): resolve package context for renamed GmsCore

    • Updates DynamiteContextFactory so it no longer assumes a single package name when creating the GMS package context.
    • It now tries valid package IDs for renamed and stock installs to avoid context lookup failures during Dynamite module loading.
  2. cdf9cf92 - fix(context): resolve renamed GmsCore package in remote contexts

    • Updates remote context/resource resolution in GooglePlayServicesUtil to try renamed (app.revanced.android.gms) and stock (com.google.android.gms) package candidates instead of one hardcoded package.
    • This keeps remote context and resource lookup working under ReVanced package naming.

@zappybiby zappybiby force-pushed the fix/gmscore-aa-compat-2026-02-pr branch from 98399d1 to 40725e4 Compare February 19, 2026 14:25
@zappybiby
Copy link
Author

This fixes the YT Music Android Auto crash, it now shows "Now playing" and forward/back track buttons on car now correctly work. Playlists do not show at all, looking into it.

@oSumAtrIX
Copy link
Member

Is this something that should be in GmsCore upstream instead?

@CrazyWolf13
Copy link

@zappybiby

Thanks for the PR!

I think so far playlist have never showed up in Android Auto at all, weirdly only podcast?
Search was recently fixed with a a new patch: ReVanced/revanced-patches#6477

But showing Playlist and Homescreen would be the ultimate thing still missing.

@zappybiby zappybiby force-pushed the fix/gmscore-aa-compat-2026-02-pr branch from 40725e4 to cdf9cf9 Compare February 19, 2026 15:08
@zappybiby
Copy link
Author

Ok I was just making sure I didn't cause a regression, I couldn't remember what displayed originally.

I just narrowed the scope of the PR to the minimum patches needed. I'm doing a few more tests to make sure things are working okay, doing another bug report dump.

@oSumAtrIX
Copy link
Member

oSumAtrIX commented Feb 19, 2026

After that rename, some runtime code paths still resolved remote/dynamite context using only the old package assumption (com.google.android.gms), which can produce an invalid module context under renamed GmsCore.

Shouldnt the patched app simply be adjusted to request under the new package name instead of modifying GmsCore? I am not sure what exactly goes wrong though and also why the new version of GmsCore regressed here

@zappybiby
Copy link
Author

zappybiby commented Feb 19, 2026

Shouldnt the patched app simply be adjusted to request under the new package name instead of modifying GmsCore? I am not sure what exactly goes wrong though and also why the new version of GmsCore regressed here

Revanced patch does rewrite app-side references but it cannot fix these internal GmsCore runtime lookup paths.
(example, GmsCoreSupportPatch.kt rewrites com.google.android.gms to app.revanced...)

The failing logic is in GmsCore runtime context/module loading paths
/DynamiteContextFactory.java (old createPackageContext(Constants.GMS_PACKAGE_NAME, ...))
GooglePlayServicesUtil.java (old remote context/resources using Constants.GMS_PACKAGE_NAME only)
They resolve via com.google.android.gms only.

As far as I can tell, the root cause comes from the GmsCore runtime, and a app-specific workaround Revanced patch for an internal runtime resolver bug wouldn't be the right solution.

@oSumAtrIX
Copy link
Member

I understand. Now the follow-up question would be, why did this issue not appear previously? Such a fix was not present in previous GmsCore versions

@zappybiby
Copy link
Author

Is this something that should be in GmsCore upstream instead?

The regression stems from ReVanced rename work (e6cd248) setting runtime package to app.revanced.android.gms. So this would primarily be a ReVanced fork issue AFAIK

why did this issue not appear previously? Such a fix was not present in previous GmsCore versions

Before e6cd2487, there was no package-name mismatch.
Old code paths using com.google.android.gms were still correct because GmsCore itself used that identity.

Before e6cd248 Rename

 1. Android Auto triggers `YT Music -> MusicBrowserService.onGetRoot()`.
  2. That flow enters Google certificates loading via Dynamite.
  3. In GmsCore, `DynamiteContextFactory.createDynamiteContext()` used:
     `originalContext.createPackageContext(Constants.GMS_PACKAGE_NAME, 0)`
     (old code at `DynamiteContextFactory.java:52` on `origin/main`).
  4. `Constants.GMS_PACKAGE_NAME` is `com.google.android.gms`.
  5. When runtime identity also matches `com.google.android.gms`, this resolves to the active GmsCore package context.
  6. Result: Dynamite context is valid, GoogleCertificates initialization succeeds, no crash from this path.

After Rename (e6cd248 regression)

  Android Auto connects
   1. `e6cd2487` changes runtime app id to `app.revanced.android.gms`
     (`play-services-core/build.gradle:122`).
  2. The runtime lookups above still request only `com.google.android.gms`.
  3. In side-by-side setups, both packages can coexist:
     - stock `com.google.android.gms`
     - renamed `app.revanced.android.gms`
  4. Old-name-only lookup can resolve the stock package context instead of renamed GmsCore context.
  5. In the reported crash chain, `GoogleCertificatesImpl` is tagged from stock package/version
     (`:com.google.android.gms@260438035@26.04.38`) and throws
     `Missing DynamiteApplicationContext`.
  6. Result: context/module source mismatch in this flow -> AA media-browser startup crash/spinner behavior.

After this proposed fix

Android Auto connects
-> YT Music: MediaBrowserService.onGetRoot()
-> GmsCore context resolution now tries:
   1) BuildConfig.APPLICATION_ID
   2) USER_MICROG_PACKAGE_NAME
   3) GMS_PACKAGE_NAME (legacy fallback)
-> Renamed GmsCore context is selected first
-> Dynamite/module context is valid
-> GoogleCertificates path initializes

And if a future commit changes applicationId again, generated BuildConfig.APPLICATION_ID changes automatically.

@oSumAtrIX
Copy link
Member

oSumAtrIX commented Feb 19, 2026

The regression stems from ReVanced rename work (e6cd248) setting runtime package to app.revanced.android.gms. So this would primarily be a ReVanced fork issue AFAIK

But so did our older fork of GmsCore, but still the issue did not appear. We renamed the package, permissions, authorities and even beyond that a couple more things that were not necessary. So something must have changed.

@CrazyWolf13
Copy link

I tested this on android auto on my car and worked fine, no crashes.

Thanks a lot for the fix!

@zappybiby zappybiby marked this pull request as ready for review February 19, 2026 18:13
@oSumAtrIX
Copy link
Member

@zappybiby #290 (comment) got an answer for this?

@zappybiby
Copy link
Author

zappybiby commented Feb 19, 2026

@zappybiby #290 (comment) got an answer for this?

I did look at both git history of Revanced patches including things like gmscore / Android Auto related commits.

  • Constants.GMS_PACKAGE_NAME has stayed com.google.android.gms
  • DynamiteContextFactory has used createPackageContext(Constants.GMS_PACKAGE_NAME, 0) from when that file was introduced
    (ff4987f).
  • GooglePlayServicesUtil.getRemoteContext() / getRemoteResources() used old-only Constants.GMS_PACKAGE_NAME from when
    they were implemented (ff4987f) until our fix (cdf9cf9).

What did change recently with runtime:

  • applicationId switched to app.revanced.android.gms in play-services-core/build.gradle (e6cd248/c778936c)
  • USER_MICROG_PACKAGE_NAME switched to app.revanced.android.gms in Constants.java (2e279c4/cdde0c6d)

I believe the root cause for this specific problem stemmed from the recent renaming commit.

I tested once more tonight and there are no crashes when connecting to AA and I am not seeing any of those errors in the logs.

@oSumAtrIX
Copy link
Member

I may have to look into Constants.GMS_PACKAGE_NAME then. If its used for internal code thats not related to package name or the renamed stuff, we may have to create a new constant for the renamed package name. Its not unlikely other internal code could depend on this constant being the original gms. Also, it looks like announcements stopped working with the latest changes, but perhaps this PR also fixes that? Do you receive announcements from say youtube?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Youtube Music - GmsCore support): Issues and crashes after updating GmsCore

3 participants

Comments