Fix Missing DynamiteApplicationContext after GmsCore package rename#290
Fix Missing DynamiteApplicationContext after GmsCore package rename#290zappybiby wants to merge 2 commits intoReVanced:mainfrom
Conversation
98399d1 to
40725e4
Compare
|
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. |
|
Is this something that should be in GmsCore upstream instead? |
|
Thanks for the PR! I think so far playlist have never showed up in Android Auto at all, weirdly only podcast? But showing Playlist and Homescreen would be the ultimate thing still missing. |
40725e4 to
cdf9cf9
Compare
|
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. |
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. The failing logic is in GmsCore runtime context/module loading paths 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. |
|
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 |
The regression stems from ReVanced rename work (e6cd248) setting runtime package to
Before Before e6cd248 RenameAfter Rename (e6cd248 regression)After this proposed fixAnd if a future commit changes applicationId again, generated BuildConfig.APPLICATION_ID changes automatically. |
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. |
|
I tested this on android auto on my car and worked fine, no crashes. Thanks a lot for the fix! |
|
@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.
What did change recently with runtime:
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. |
|
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? |
|
@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. |
|
I am waiting for an answer to my comment above |
|
By announcement do you mean notification? |
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 |
|
@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? |
cdf9cf9 to
d2ec265
Compare
|
I have confirmed that commit d2ec265 alone is sufficient to resolve the Android Auto problem. Narrowed PR scope to that file specifically. |
|
Is it possible for this to be merged? I mainly use YouTube music in my car but can't now. |
|
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 |
|
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! |
|
So, the question is, why would 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 |
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 |
|
Update: Successful Physical Device Test on Samsung S23 Ultra (Android 16) |
|
I need to understand the code before it is in the codebase. The previous question is still pending |
|
@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. |
|
No, because upstream intends the app to be a GMS replacement, implying the package name matches official gms |
|
I made a write-up here that should hopefully provide more information @oSumAtrIX https://gist.github.com/zappybiby/76135abdd659c4d8e35e8730d048f6cb |
|
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. |
|
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. |
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.
could you upload your apk somewhere? |
https://github.com/zappybiby/GmsCore/releases/tag/d2ec2657-dynamite-context-factory-test |
|
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. |
|
Thank you for taking the time to get through this protracted review and getting a fix worked out! |
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. |
This comment was marked as off-topic.
This comment was marked as off-topic.
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 |
|
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. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
|
Moving to #308 |


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
googlecertificatespath 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.GoogleCertificatesImpljava.lang.IllegalStateException: Missing DynamiteApplicationContextcom.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 asc778936c):feat: Allow side-by-side installation with Google services by renaming permissions and authoritiesWhat changed in that commit
play-services-core/build.gradle:122applicationId = "app.revanced.android.gms"play-services-core/build.gradle:134resValue "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
googlecertificatesDynamite path and terminates with:java.lang.IllegalStateException: Missing DynamiteApplicationContext.Environment
SM-S926U(e2q)16(SDK36)2026-01-01samsung/e2qsqw/e2q:16/BP2A.250605.031.A3/S926USQS4CZA1:user/release-keyscom.google.android.projection.gearhead16.1.660414-release(versionCode=161660414)8.10.52(versionCode=81052240)0.3.13.2.250932(versionCode=250932004)2026-02-18 20:34:18Evidence
1) Crash loop in YT Music media browser startup
Full stacktrace (raw)
2) Dynamite
googlecertificatescontext created immediately before crash3) Android Auto is actively binding YT Music media service
4) Additional service/module warnings seen during the same window
Proposed fixes in this PR
d2ec2657-fix(chimera): resolve package context for renamed GmsCoreDynamiteContextFactoryso it no longer assumes a single package name when creating the GMS package context.