Skip to content

Fix Missing DynamiteApplicationContext after GmsCore package rename#290

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

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.

@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
@oSumAtrIX oSumAtrIX self-requested a review February 19, 2026 15:10
@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?

@CrazyWolf13
Copy link

@oSumAtrIX could this PR be merged then, or do you need to fix anything?

What do you mean by announcements? Like Notifications, or those full screen popup for premium ad?

I got contacted via discord multiple times from people that currently cannot use android auto at all and asked me for instructions how to get it working.
So maybe this Pr could get merged and a new release published, that yt music will be fully usable again?

@oSumAtrIX
Copy link
Member

I am waiting for an answer to my comment above

@UnknownAPI
Copy link

By announcement do you mean notification?

@zappybiby
Copy link
Author

zappybiby commented Feb 22, 2026

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.

It's a valid concern as Constants.GMS_PACKAGE_NAME is indeed used in mixed canonical / internal ways throughout the repo.

It's something that certainly would be good to address in a future PR

In this PR, Constants.GMS_PACKAGE_NAME remains canonical and is still used as fallback.

The PR only updates lookup in DynamiteContextFactory, it doesn't affect call sites like setpackage or setclassname

I think it is still okay to push this to fix AA and a seperate PR can be done for handling gms package name

@oSumAtrIX
Copy link
Member

oSumAtrIX commented Feb 23, 2026

@zappybiby I am having a hard time to understand the changes, their needs and if another way is better to solve this issue. Are you up for a quick discussion on our discord at https://revanced.app/discord (simply ping us) or discourse@revanced.app?

@zappybiby zappybiby force-pushed the fix/gmscore-aa-compat-2026-02-pr branch from cdf9cf9 to d2ec265 Compare February 23, 2026 18:02
@zappybiby
Copy link
Author

I have confirmed that commit d2ec265 alone is sufficient to resolve the Android Auto problem. Narrowed PR scope to that file specifically.

@jenno-verdonck
Copy link

Is it possible for this to be merged? I mainly use YouTube music in my car but can't now.

@GG-OMEGA
Copy link

GG-OMEGA commented Mar 5, 2026

The "new ID" I am referring to is app.revanced.android.gms (renamed from com.google.android.gms in build.gradle).
​To clarify, this is not a client-side (YouTube patch) issue. Even when the patched YouTube app correctly binds to the new GmsCore package, GmsCore itself crashes internally during the Android Auto initialization.
​The crash happens because GmsCore's internal DynamiteContextFactory is still hardcoded to look for its own modules under the old ID (com.google.android.gms). On my S23 Ultra, this leads it to fetch a context from the stock Google Play Services instead of its own, causing the Missing DynamiteApplicationContext error.
​This PR is the correct fix because it ensures GmsCore's internal lookups are consistent with its own applicationId, making it a GmsCore-side fix rather than a patch fix.

@oSumAtrIX
Copy link
Member

The "new ID" I am referring to is app.revanced.android.gms (renamed from com.google.android.gms in build.gradle).

Again, this was the case before as well, yet the crash did not happen, so what changed

@GG-OMEGA
Copy link

GG-OMEGA commented Mar 5, 2026

Hi @zappybiby, since I had some trouble running the GitHub Actions build on my end, would it be possible for you to provide a pre-compiled APK from this branch? I’d like to install it on my S23 Ultra immediately and verify the Android Auto fix for everyone. A download link would be greatly appreciated!

@memen45
Copy link

memen45 commented Mar 5, 2026

So, the question is, why would Constants.GMS_PACKAGE_NAME be returning a different or incorrect package name after the renaming? Where is it defined?

Since this constant is used in many places, it is useful to know whether there is an issue with the renaming commit in general. If so, maybe the value of the constant itself should be changed? Or is there something unique about the DynamiteApplicationContext that it requires a separate constant?

@oSumAtrIX
Copy link
Member

Since this constant is used in many places, it is useful to know whether there is an issue with the renaming commit in general.

I think before the new changes, Constants.GMS_PACKAGE_NAME was not renamed everywhere, and a new constant was introduced, perhaps this is the issue, so we have to indeed verify where this is used and if the rename is fine everywhere where its used, if not add a second constant for the new value and use that where applicable. This would be the correct approach that handles any other potential issue from touching Constants.GMS_PACKAGE_NAME and should be addressed instead of this current PR

@GG-OMEGA
Copy link

GG-OMEGA commented Mar 6, 2026

​Update: Successful Physical Device Test on Samsung S23 Ultra (Android 16)
​I have successfully compiled and tested the fix from this PR on my Samsung S23 Ultra running Android 16 (AA version: 16.2.660664).
​Test Results:
​AA Initialization: The MissingDynamiteApplicationContext crash is 100% resolved.
​Core Functions: Song info display, playback controls (Play/Pause/Skip), and music search are all working perfectly.
​Known Issue: Playlists still do not load, but as discussed, this is a separate bug unrelated to the package name resolution fixed here.
​This PR is critical for users on newer Android versions and devices where ReVanced GmsCore must coexist with stock GMS. I highly recommend merging this fix. Huge thanks to @zappybiby for the solution!

@oSumAtrIX
Copy link
Member

I need to understand the code before it is in the codebase. The previous question is still pending

@memen45
Copy link

memen45 commented Mar 6, 2026

@oSumAtrIX Would it be useful to move this conversation to the microg/gmscore repo? This might become an issue upstream in the future if they change the application id too.

@oSumAtrIX
Copy link
Member

No, because upstream intends the app to be a GMS replacement, implying the package name matches official gms

@zappybiby
Copy link
Author

I made a write-up here that should hopefully provide more information @oSumAtrIX

https://gist.github.com/zappybiby/76135abdd659c4d8e35e8730d048f6cb

@oSumAtrIX
Copy link
Member

Thanks, so effectively previously, we were renaming GMS_PACKAGE_NAME to the new package name which is why it was working as expected. We have added a new constant now thats called USER_MICROG_PACKAGE_NAME. However if we inspect the usages of GMS_PACKAGE_NAME we notice places that call for using USER_MICROG_PACKAGE_NAME. In other words, the "fallback" mechanism shouldn't exist, instead that location of code should determine its own package name. This would dynamically work in the situation the app has the GMS_PACKAGE_NAME or USER_MICROG_PACKAGE_NAME. Unless I am missing something, a fallback mechanism like in this PR shouldnt exist and is more akin to a hack that works rather then a correct solution, assumed to be to determine ones own package name.

@oSumAtrIX
Copy link
Member

Heres an example of how we shouldve used USER_MICROG_PACKAGE_NAME instead of GMS_PACKAGE_NAME.

image

Original GmsCore intends to launch the intent on itself, however now due to the rename this wouldnt happen. With our previous fork, we globally changed GMS_PACKAGE_NAME. However some code paths truly expect the original gmscore package name:

image

This requires us to do the following:

Decide if we want to set GMS_PACKAGE_NAME to the changed package name, and replace locations where its used with USER_MICROG_PACKAGE_NAME where appropriate, or introduce a USER_MICROG_PACKAGE_NAME and use that where appropriate. The decision depends on what requires less changes.

@oSumAtrIX
Copy link
Member

In fact, I believe GmsCore should not be hardcoding its own package name as a constant where it expects its own package name, and instead only use the constant where its guaranteed to be this package name. I think in the case of upstream it doesnt matter since they expect the constant to be the own package name, but as part of our forks requirement, this must be considered in our case, so the third option is to replace all locations where GMS_PACKAGE_NAME is used, with code that dynamically determines the package name and only use GMS_PACKAGE_NAME where we definitly know that the original is expected.

@zappybiby zappybiby marked this pull request as draft March 6, 2026 19:12
Stop using GMS_PACKAGE_NAME for call sites that actually mean the installed
GmsCore APK and keep the remaining special cases explicit.

- auth-api-phone: target the user consent prompt with the runtime package.
- play-services-base core: add PackageUtils.getSelfPackageName() for generic Context sites.
- auth, credential, folsom, and games service flows: use the runtime self package for internal activity/class launches.
- login, account settings, gcm, and games UI/service code: use local packageName/getPackageName() for self broadcasts and intents.
- chime registration: read local package info and version from the installed runtime package.
- dynamite: resolve the package context directly from BuildConfig.APPLICATION_ID instead of probing fallback candidates.
- maps loader: cache the selected remote maps context and expose it through MapsRemoteContextHolder.
- mapbox, hms, and vtm backends: build resource/code contexts from the cached remote maps context instead of the embedding app context.
- mapbox native loader: stamp extracted libs against the remote maps APK version and code path.
@fjleon1980
Copy link

​Update: Successful Physical Device Test on Samsung S23 Ultra (Android 16) ​I have successfully compiled and tested the fix from this PR on my Samsung S23 Ultra running Android 16 (AA version: 16.2.660664). ​Test Results: ​AA Initialization: The MissingDynamiteApplicationContext crash is 100% resolved. ​Core Functions: Song info display, playback controls (Play/Pause/Skip), and music search are all working perfectly. ​Known Issue: Playlists still do not load, but as discussed, this is a separate bug unrelated to the package name resolution fixed here. ​This PR is critical for users on newer Android versions and devices where ReVanced GmsCore must coexist with stock GMS. I highly recommend merging this fix. Huge thanks to @zappybiby for the solution!

could you upload your apk somewhere?

@zappybiby
Copy link
Author

could you upload your apk somewhere?

https://github.com/zappybiby/GmsCore/releases/tag/d2ec2657-dynamite-context-factory-test

@zappybiby
Copy link
Author

Closing this PR based on the review feedback.

The correct fix is to update call sites to use the appropriate package identity ("USER_MICROG_PACKAGE_NAME", "GMS_PACKAGE_NAME", or dynamically determined self package) rather than introducing a fallback resolver.

Since that requires broader changes, I'll rework this and submit a new PR.

@zappybiby zappybiby closed this Mar 8, 2026
@CrazyWolf13
Copy link

Thank you for taking the time to get through this protracted review and getting a fix worked out!

@oSumAtrIX
Copy link
Member

The correct fix is to update call sites to use the appropriate package identity ("USER_MICROG_PACKAGE_NAME", "GMS_PACKAGE_NAME", or dynamically determined self package) rather than introducing a fallback resolver.

There are multiple ways to solve the dynamic part, instead of using Android APIs to determine ones package name at runtime, a buildconfig constant specifying the package name can be used. It is also important to weight the amounf of changes the fork needs to do. The less the better as its easier to update the fork from upstream. The solution in this PR works for the specific case with dynamite but still leaves potential issues in other places of the fork where the original gms package name is expected.

@Wetzel402

This comment was marked as off-topic.

@MohmmadQunibi
Copy link

could you upload your apk somewhere?

https://github.com/zappybiby/GmsCore/releases/tag/d2ec2657-dynamite-context-factory-test

I get the following error when trying to update the app...
"App not installed as package appears to be invalid"

Thanks for your work on this! I'm excited to see it fixed.

Just re-sign the app again

@fjleon1980
Copy link

could you upload your apk somewhere?

https://github.com/zappybiby/GmsCore/releases/tag/d2ec2657-dynamite-context-factory-test

I get the following error when trying to update the app...
"App not installed as package appears to be invalid"
Thanks for your work on this! I'm excited to see it fixed.

Just re-sign the app again

can you provide the steps? this may take weeks / months to get fixed at this point so if we can get a temporary workaround it would be great

@zappybiby
Copy link
Author

I believe you'll get that error if you try to install over an existing Revanced coregms install (i.e. 'updating' the package).

The simplest thing would be to uninstall the existing install and then install the new patched file.

@Wetzel402

This comment was marked as off-topic.

@cociweb

This comment was marked as off-topic.

@oSumAtrIX

This comment was marked as resolved.

@oSumAtrIX
Copy link
Member

Moving to #308

@ReVanced ReVanced locked as too heated and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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