Skip to content

Isolate the IServiceCallback registration behind its own class - #926

Merged
JingMatrix merged 1 commit into
masterfrom
fix/issue-925-iservicecallback-pre-r
Aug 21, 2026
Merged

Isolate the IServiceCallback registration behind its own class#926
JingMatrix merged 1 commit into
masterfrom
fix/issue-925-iservicecallback-pre-r

Conversation

@JingMatrix

@JingMatrix JingMatrix commented Aug 20, 2026

Copy link
Copy Markdown
Owner

On Android 9 the daemon logs a NoClassDefFoundError for android.os.IServiceCallback$Stub before it prints anything of its own. The reported stack tops out at VectorDaemon.main with ClassLoader.loadClass frames, which is the giveaway: this is ART resolving classes while it verifies registerProxyService, not while it runs it.

IServiceCallback only exists since Android R, and the callback was written as an anonymous object : IServiceCallback.Stub() inside the SDK_INT >= R branch. That gate could never work — ART resolves every type a method mentions at verification time, and loading that type resolves its superclass, so the reference alone was enough.

ART resolves the superclass of every type a method mentions when it
verifies that method, not when the branch mentioning it runs. The
`Build.VERSION.SDK_INT >= R` gate therefore never got a chance to help:
verifying registerProxyService resolved the anonymous callback, that
resolved `android.os.IServiceCallback$Stub`, and on Android 9 the daemon
logged a NoClassDefFoundError for its very first call even though the
guarded code was never executed.

Move the callback into a holder object that the gate only touches on R
and newer, so the resolution is deferred to its class initialization,
and pin the holder in the R8 rules so a release build cannot inline it
back into the caller and reintroduce the reference.

Fixes #925
@JingMatrix
JingMatrix merged commit 3eae64f into master Aug 21, 2026
1 check passed
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.

Android 9: VectorDaemon throws NoClassDefFoundError for android.os.IServiceCallback$Stub on latest Debug 3098

1 participant