Skip to content

Preserve MainHook constructor in release builds - #313

Merged
JingMatrix merged 3 commits into
JingMatrix:masterfrom
7heMech:fix-mainhook-constructor
Oct 23, 2026
Merged

JingMatrix merged 3 commits into
JingMatrix:masterfrom
7heMech:fix-mainhook-constructor

Conversation

@7heMech

@7heMech 7heMech commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

In release builds of ChromeXt 3.9.0, R8 optimization stripped the parameterless constructor for org.matrix.chromext.MainHook because keeping only the class (-keep class org.matrix.chromext.MainHook) does not preserve its default constructor under recent R8/AGP versions.

Since Xposed / Vector instantiates the entry point reflectively using the default constructor, the module failed to instantiate at runtime on release builds, rendering hooks inactive across all supported browsers.

Changes

  • Updated app/proguard-rules.pro to explicitly keep public <init>(); on org.matrix.chromext.MainHook.
  • Added a verification step in .github/workflows/android.yml using apkanalyzer to verify that org.matrix.chromext.MainHook.<init>()V is preserved in unsigned release APKs.

Verification

  • Built release APK with ./gradlew assembleRelease and verified with apkanalyzer that MainHook.<init>()V is present in DEX.
  • Installed the rebuilt APK and verified that Vector successfully instantiates the module and hooks function in browsers.

In release builds, R8 optimization stripped the parameterless constructor for MainHook because keeping only the class does not prevent R8 from shrinking default constructors. Because Xposed / Vector instantiates the entry point reflectively, the module failed to instantiate and hook.

Explicitly keep the public no-argument constructor in ProGuard rules and add an apkanalyzer verification step to the GitHub Actions release workflow.
@JingMatrix
JingMatrix merged commit 80d244c into JingMatrix:master Oct 23, 2026
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.

2 participants